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

Instruction

Alright! Let's take a look at the very first example:

SELECT
  OpenDate,
  Name,
  LEAD(Name) OVER(ORDER BY OpenDate ASC) AS Lead
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.