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

Well done! Let's try another exercise.

Exercise

Calculate the total monthly revenue for each month of 2017, along with the revenue change as compared to the previous month. Show three columns: revenue_month, total_revenue, and delta.

In the first row, leave the delta value as NULL. Order the rows by month.

Stuck? Here's a hint!

Use the following expression to calculate the delta:

SUM(amount) - LAG(SUM(amount), 1) OVER (ORDER BY EXTRACT(month FROM order_date)) AS delta