Code RoomMulti-join cartesian product inflates totals
HardPrep Room Coding #2262

Multi-join cartesian product inflates totals

Code reviewDatabases & SQLDistributed systemsMid–Senior~25 min

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.

0:00 of about 25 min
Mark a line and say what kind of problem it is.0 findings
1SELECT c.id,
2 c.name,
3 SUM(o.amount) AS revenue,
4 COUNT(p.id) AS payment_count
5FROM customers c
6JOIN orders o ON o.customer_id = c.id
7JOIN payments p ON p.customer_id = c.id
8WHERE o.created_at >= '2026-01-01'
9GROUP BY c.id, c.name;
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.