Instruction
Okay! Let's do two similar exercises to practice the pattern.
Exercise
For each shipping country, we want to find the average count of unique products in each order. Show the ShipCountry and AvgDistinctItemCount columns. Sort the results by count, in descending order.
In the inner query, find the number of distinct products in each order and select it alongside the ShipCountry column. In the outer query, apply the proper aggregation.
Stuck? Here's a hint!
Use the following template:
WITH OrderDistinctItems AS ( ... ) SELECT ... FROM OrderDistinctItems GROUP BY ... ORDER BY ... DESC;




