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

Instruction

Alright. Take a look at the very first example:

SELECT
  name, 
  opened,
  LEAD(name) OVER(ORDER BY opened)
FROM website;

The analytic function here is LEAD(name). LEAD with a single argument in the parentheses looks at the next row in the given order and shows the value in the column specified as the argument. Take a look:

Lead

Exercise

Run the template from the instruction and study the result of LEAD(name).

Note that for each website, the function shows the name of the website that was opened next. The last row doesn't show any value, because there is no 'next' row.