Deals Of The Week - 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: first_name, last_name, and avg_item_count.

Stuck? Here's a hint!

In the inner query, find the total number of all products in each order with an order_date 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.order_date >= '2016-01-01' AND O.order_date < '2017-01-01'