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

Instruction

Very well done! Let's try one more before we move on.

Exercise

For each employee, determine the average number of items they processed per order, for all orders placed in 2016. The number of items in an order is defined as the sum of all quantities of all items in that order. Show the following columns: FirstName, LastName, and AvgItemCount.

Stuck? Here's a hint!

In the inner query, find the total number of all products in each order with an OrderDate in 2016, and select it alongside the ID of the employee responsible for the order. In the outer query, join the CTE with the Employees table.

Use the following condition to select orders from 2016:

WHERE O.OrderDate >= '2016-01-01' AND O.OrderDate < '2017-01-01'