On January 21th at 14:15 UTC , progression through exercises will be unavailable for 10 minutes due to a planned maintenance break.
Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Total revenue for multiple periods
Calculating deltas
Creating "revenue in quarters" reports


Very good! It's time for an additional exercise.


For each year, calculate the count of orders placed in the current year and the count of orders placed in the previous year. Show three columns: OrderYear, OrderCount, and PreviousYearOrderCount.

In the first row, leave the previous year value as NULL. Order the rows by year.

Stuck? Here's a hint!

Use the following expression in the last column:

LAG(COUNT(OrderId), 1) OVER (ORDER BY DATEPART(Year, OrderDate))