\pset pager off
\pset tuples_only on
\pset fieldsep '\t'
SELECT 'acct_yday', count(*) AS n, l.account_id, a.name, l.group_id, g.name, l.error_phase, l.error_owner
FROM ops_error_logs l
LEFT JOIN accounts a ON a.id=l.account_id
LEFT JOIN groups g ON g.id=l.group_id
WHERE l.created_at >= TIMESTAMPTZ '2026-05-11 00:00:00+08' AND l.created_at < TIMESTAMPTZ '2026-05-12 00:00:00+08'
  AND l.account_id IS NOT NULL
GROUP BY l.account_id,a.name,l.group_id,g.name,l.error_phase,l.error_owner
ORDER BY n DESC LIMIT 25;
-- 20:30-21:20 全部账号错误，确认是否单账号爆发
SELECT 'window_acct', count(*) AS n, l.account_id, a.name, l.group_id, g.name
FROM ops_error_logs l
LEFT JOIN accounts a ON a.id=l.account_id
LEFT JOIN groups g ON g.id=l.group_id
WHERE l.created_at >= TIMESTAMPTZ '2026-05-11 20:30:00+08' AND l.created_at < TIMESTAMPTZ '2026-05-11 21:20:00+08'
GROUP BY l.account_id,a.name,l.group_id,g.name ORDER BY n DESC LIMIT 20;
