Beginner Case 10 of 50

Case 010: The Big Spenders

customersorders

The order-count numbers from the loyalty tiers came back, and something looks off — a customer with ten $50 orders is outranking someone who placed three $3,000 orders.

"Order count doesn't tell me revenue," the manager says. "Could you show me who's actually spent the most — over $5,000 total? That's what should count for a VIP tier."

The data Alex is looking at

customers
idnamecountry
1SamGermany
2NinaCanada
3DavidBrazil
4MayaJapan
5DanielAustralia
… 1 more row
orders
idcustomer_idproductamountorder_date
1011Keyboard25002026-01-05
1023Mouse12002026-01-08
1032Headphones35002026-01-10
1044Monitor120002026-01-12
1051Webcam45002026-02-03
… 4 more rows
TASK

Help Alex answer the manager:

“Find every customer whose combined order total is more than $5,000, showing that total.”
SQL editor Ctrl+Enter to run
Write a query above and hit Run to see what comes back.
No hints requested yet — click "Get a hint" when you're stuck.
Alex's final query — this is for reference. Copy it into your own thinking, not into the editor above.
SELECT customers.name, SUM(orders.amount) AS total_spent FROM customers JOIN orders ON customers.id = orders.customer_id GROUP BY customers.name HAVING SUM(orders.amount) > 5000;
What that query returns
Case Debrief GROUP BY, SUM, HAVING
  • HAVING filters grouped rows AFTER aggregation happens — exactly what you need when the condition depends on an aggregate like SUM(), not a raw column value.

Case closed.

Ready for the next one?

Next: Case 011 — Sales by Category →