Beginner Case 11 of 50

Case 011: Sales by Category

ordersproducts

Budget planning for next quarter is coming up, and the manager wants to know where to double down.

"Which product categories are actually driving revenue? I don't want to guess when we decide where next quarter's budget goes."

The data Alex is looking at

orders
idcustomer_idproductamountorder_date
1011Keyboard25002026-01-05
1023Mouse12002026-01-08
1032Headphones35002026-01-10
1044Monitor120002026-01-12
1051Webcam45002026-02-03
… 4 more rows
products
idnamecategoryprice
1KeyboardAccessories2500
2MouseAccessories1200
3HeadphonesAudio3500
4MonitorDisplays12000
5WebcamAccessories4500
… 2 more rows
TASK

Help Alex answer the manager:

“Show total revenue for each product category.”
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 products.category, SUM(orders.amount) AS category_revenue FROM orders JOIN products ON orders.product = products.name GROUP BY products.category ORDER BY category_revenue DESC;
What that query returns
Case Debrief JOIN + GROUP BY across tables
  • You can JOIN on any matching columns, not just IDs — here, product names link orders to their category.
  • Combining JOIN with GROUP BY is how most real business reports get built.

Case closed.

Ready for the next one?

Next: Case 012 — The Full Order Detail →