Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Healthy Shop database
MULTIPLE JOINs – Exercises
9. Exercise 5 – Get to know the SalesHistory table

Instruction

Don't give up! Here comes the next table!

Exercise

This time we'll add information about the shop's daily sales.

The SalesHistory table consists of the following three columns:

  • ProductId - the ID of a given product,
  • Date - the date of sale, and
  • Amount - the amount of a given product sold on a particular day.

For every day in the SalesHistory table show the sales of the products with ID's 13, 18, and 15.

Display the date, name, Amount, and calorific value of a product.

Order the results by date and then by calorific value.

Stuck? Here's a hint!

Type:

SELECT
  Date,
  P.Name,
  Amount,
  Calories
FROM Product P
JOIN SalesHistory Sh
  ON P.Id = Sh.ProductId
JOIN NutritionData ND
  ON ND.ProductId = P.Id
WHERE P.Id IN (13, 18, 15)
ORDER BY Date, Calories