Code Room
Code reviewMedium
Question
Review this SQL that powers a 'daily active users' report. created_at is a UTC timestamptz; the business reports in America/Los_Angeles.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
SELECT date_trunc('day', created_at) AS day, count(DISTINCT user_id) AS dauFROM eventsWHERE created_at >= now() - interval '30 days'GROUP BY date_trunc('day', created_at)ORDER BY day;Run or narrate your approach, then ask the coach.