Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

LEAD windowing function

Declaration

LEAD ( scalar_expression [ , offset ] [ , default ] ) [ IGNORE NULLS | RESPECT NULLS ] OVER ( [ partition_by_clause ] order_by_clause )

Description

LEAD accesses data from a subsequent row in the same result set without the use of a self-join.

Use this analytic function in a SELECT statement to compare values in the current row with values in a following row.

BusinessEntityID SalesYear CurrentQuota NextQuota

---------------- ----------- --------------------- ---------------------

275 2005 367000.00 556000.00

275 2005 556000.00 502000.00

275 2006 502000.00 550000.00

275 2006 550000.00 1429000.00

275 2006 1429000.00 1324000.00

275 2006 1324000.00 0.00

See Also

LAG

TOCIndex