Best April deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Reports with revenue in categories
Summary

Instruction

Before we start creating reports that use product categories, let's get comfortable with joining tables. Look at the following query:

SELECT
  p.product_name,
  c.category_name,
  oi.amount
FROM order_items oi
JOIN products p
  ON oi.product_id = p.product_id
JOIN categories c
  ON p.category_id = c.category_id
WHERE order_id = 10480;

The query returns some basic order info by selecting columns from three tables: the product name from products, the category name from categories, and the amount paid from order_items. Notice the JOINs we use here; we'll have to join these three tables quite often in this part.

Exercise

For all order items from the order with the ID of 10498, show the following columns:

  1. product_id
  2. category_name
  3. product_name
  4. amount

Stuck? Here's a hint!

Use the same tables as shown in the example code.