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

Instruction

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

SELECT
  name,
  opened,
  LAST_VALUE(opened) OVER(ORDER BY opened)
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.