Explore Library
Code QuizAdvanced

Filtering Aggregated Order Totals

Spot the mistake in a JOIN with GROUP BY that tries to filter by a total.

Codesql
SELECT c.name, SUM(o.amount) AS total
FROM customers c
JOIN orders o ON o.customer_id = c.id
WHERE SUM(o.amount) > 1000
GROUP BY c.name;

What is the bug in this query?