Beginner Case 12 of 50

Case 012: The Full Order Detail

order_itemsorderscustomersproducts

ByteMart's order data used to be simple — one row per order, one amount. Now that the catalog's grown, orders are broken down into individual line items instead. A customer is disputing a charge, and finance needs to see the actual line items behind it — not just the order total. The manager brings it to Alex.

"Could you pull up exactly what each customer bought, item by item? A total on its own doesn't hold up in a dispute."

The data Alex is looking at

order_items
order_idproduct_idquantity
10112
10121
10231
10323
10451
… 29 more rows
orders
idcustomer_idorder_date
10112026-01-05
10222026-01-08
10332026-01-12
10412026-01-20
10542026-02-01
… 23 more rows
customers
idnamecountry
1SamGermany
2NinaCanada
3DavidGermany
4MayaJapan
5DanielCanada
… 5 more rows
products
idnamecategoryprice
1KeyboardAccessories2500
2MouseAccessories1200
3HeadphonesAudio3500
4MonitorDisplays12000
5LaptopComputers60000
… 5 more rows
TASK

Help Alex answer the manager:

“List every order item together with the customer's name, the product name, and the quantity ordered.”
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 AS customer, products.name AS product, order_items.quantity FROM order_items JOIN orders ON orders.id = order_items.order_id JOIN customers ON customers.id = orders.customer_id JOIN products ON products.id = order_items.product_id;
What that query returns
Case Debrief Joining 3+ tables
  • JOINs chain together — each one just needs its own ON condition linking two tables at a time. There's no real limit to how many you can chain.

Case closed.

Ready for the next one?

Next: Case 013 — Revenue by Country and Category →