Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Customer activity
Finding good customers
Summary

Instruction

Good job! Let's do one more exercise to practice writing queries with Common Table Expressions.

Exercise

Find out the average number of orders placed in the last 180 days by customers who have been active (made a purchase) in the last 30 days. Name the column AvgOrders180. Make sure that your average isn't integer.

In the Common Table Expression determine the number of orders placed in the last 180 days by each active customer. Then, in the outer query determine the average.

Stuck? Here's a hint!

To make sure that your average isn't integer multiply the value inside the AVG() function by 1.0.