Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Basic multi-level aggregation
5. Multi-level aggregation – step 2
Multi-level aggregation in groups
Multi-level aggregation with custom classification
Three or more aggregation levels
Summary

Instruction

Okay! Now that we have a query that counts the number of items in each order, let's turn it into a CTE and calculate the average number of items for all orders.

Exercise

We've turned the query you wrote in the previous exercise into a CTE named OrderItemsCounts. Now you need to complete the outer query, which should show a single column named AvgItemCount that contains the average number of items in a single order.

Stuck? Here's a hint!

Outside the parentheses, add the following outer query:

SELECT
  AVG(ItemCount) AS AvgItemCount 
FROM OrderItemsCounts;