Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Total revenue for multiple periods
Calculating deltas
Creating "revenue in quarters" reports
Summary

Instruction

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

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))