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

Instruction

Well done. Of course, we can also find the last value: simply use LAST_VALUE(x) instead:

SELECT
  Name,
  OpenDate,
  LAST_VALUE(OpenDate) OVER(ORDER BY OpenDate ASC) AS LastOpenDate
FROM Website;

Now, we'll see the opening date of each website plus the opening day of the last (most recent) website... or will we? Let's find out.

Exercise

Run the template from the instruction.

As you can see, the result is a bit different from our expectations. LAST_VALUE() shows the current value instead of the highest value.