Instruction
Great job! It's now your turn to create a "revenue in quarters" report!
Exercise
Create a "revenue in quarters" report showing the number of orders placed in each quarter of each year. The final report should look like this:
| year | Q1 | Q2 | Q3 | Q4 |
|---|---|---|---|---|
| 2016 | 0 | 0 | 70 | 82 |
| 2017 | 92 | 93 | 103 | 120 |
| 2018 | 182 | 88 | 0 | 0 |
Order the rows by year.
Stuck? Here's a hint!
Calculate the first column like this:
EXTRACT(year FROM order_date) AS year
Remember to group by the first column. All the other columns should be calculated using the following pattern:
COUNT(CASE WHEN EXTRACT(quarter FROM order_date) = X THEN amount END) AS QX




