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.ProductName,
  C.CategoryName,
  OI.Amount
FROM OrderItems OI
JOIN Products P
  ON OI.ProductId = P.ProductId
JOIN Categories C
  ON P.CategoryId = C.CategoryId
WHERE OrderId = 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 OrderItems. 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. ProductId
  2. CategoryName
  3. ProductName
  4. Amount

Stuck? Here's a hint!

Use the same tables as shown in the example code.