Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
LEAD() and LAG()
12. The LAG(x, y, z) function
FIRST_VALUE(), LAST_VALUE()
Summary

Instruction

The last version of LAG() takes three arguments and is very similar to LEAD() with three arguments:

SELECT
  Name,
  OpenDate,
  LAG(OpenDate,2,'2000-01-01') OVER(ORDER BY OpenDate ASC)
FROM Website;

The last argument is the value displayed when no "lag" (previous) row can be found. Remember that this value must be of the same data type as the column.

Exercise

Modify the template from the previous exercise so that it shows -1.00 for rows with no revenue value 3 days before.

Stuck? Here's a hint!

Use LAG() with three arguments.