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_id | product_id | quantity |
|---|---|---|
| 101 | 1 | 2 |
| 101 | 2 | 1 |
| 102 | 3 | 1 |
| 103 | 2 | 3 |
| 104 | 5 | 1 |
| … 29 more rows | ||
orders
| id | customer_id | order_date |
|---|---|---|
| 101 | 1 | 2026-01-05 |
| 102 | 2 | 2026-01-08 |
| 103 | 3 | 2026-01-12 |
| 104 | 1 | 2026-01-20 |
| 105 | 4 | 2026-02-01 |
| … 23 more rows | ||
customers
| id | name | country |
|---|---|---|
| 1 | Sam | Germany |
| 2 | Nina | Canada |
| 3 | David | Germany |
| 4 | Maya | Japan |
| 5 | Daniel | Canada |
| … 5 more rows | ||
products
| id | name | category | price |
|---|---|---|---|
| 1 | Keyboard | Accessories | 2500 |
| 2 | Mouse | Accessories | 1200 |
| 3 | Headphones | Audio | 3500 |
| 4 | Monitor | Displays | 12000 |
| 5 | Laptop | Computers | 60000 |
| … 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.”
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.