Instruction
Good job! It's not that difficult, as you can see.
Whenever you write a report with multi-level aggregation, it's usually easiest to start by creating the inner query independently, and then turning it into a CTE by adding an outer query.
Now it's time to write your first multi-level aggregation report – without our assistance!
Exercise
What's the average number of products in each category? Show a single value in a column named avg_product_count.
In the inner query, calculate the number of products for each category ID. In the outer query, find the average product count.
Stuck? Here's a hint!
Use the following template:
WITH products_category_count AS ( ... ) SELECT ... FROM products_category_count;




