Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Simple OVER()
PARTITION BY
Ranking functions
Window frame
Analytic functions
25. Analytic functions – Exercise 3
ORDER BY PARTITION BY
Order of evaluation
Summary

Instruction

Simply perfect. We'll now try to write a more complicated version of the previous exercise.

Exercise

For each rental date, show the rental_date, the sum of payment amounts (column name payment_amounts) from single_rental on that day, the sum of payment_amounts on the previous day and the difference between these two values.

Stuck? Here's a hint!

In this exercise, it is best to create a temporary table using WITH table_name AS (...). In the temporary table, group payment_amounts by dates. Once this table is ready, you can easily select the daily sum from that temporary table and the use the lag function to retrieve the value on the previous day.