Introduction
Exercises with artist, museums and their pieces of art
Exercises with the band members table
Exercises with tables of Japanese 100 Yen store
Exercises with employees, salaries and benefits

Instruction

Great! Here comes the next one!

Exercise

Select the name of each product category along with the revenue (name that column revenue) that it generated between 2016 and 2018.
Sort the results by revenue in descending order.

Show a given product category even if there were no sales for a particular category. In this case, the revenue has to be null.

Stuck? Here's a hint!

You need to LEFT JOIN following tables together:

• categories,
• products,
• order_items,
• orders.

The BETWEEN condition for dates will remove any row that does not fulfill the date condition (it will also remove rows with no sales at all). We have to consider rows without any sales in this period in a separate condition.

Code editor

TableConsole