Code Room
Code reviewHard
Question
Review this SQL that reports revenue per customer.
Each order has multiple payments and each customer has many orders.
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 c.id, c.name, SUM(o.amount) AS revenue, COUNT(p.id) AS payment_countFROM customers cJOIN orders o ON o.customer_id = c.idJOIN payments p ON p.customer_id = c.idWHERE o.created_at >= '2026-01-01'GROUP BY c.id, c.name;Run or narrate your approach, then ask the coach.