LEAD

Returns the value from a preceding row at the specified offset from the current value. Offsets start at 1. The offset can be any positive integer. If the offset is null or greater than the number of values in the window, a default value is returned, or null if unspecified.

ParameterTypeDescription
value
any
The name of the column to evaluate
offset
integer
The number of rows to offset
default value
any
The value to put if there are no more rows that meet the partition requirement
Returns: any

Example

query:

SELECT account, create_date, order_value, LEAD(order_value, 1, -1) OVER (PARTITION BY account ORDER BY create_date)
  FROM jun_2017_orders

result:

account create_date order_value lead
Betasoloin 2017-06-03 5100 2887
Betasoloin 2017-06-04 2887 4492
Betasoloin 2017-06-06 4492 5182
Betasoloin 2017-06-09 5182 1036
Betasoloin 2017-06-24 1036 -1
Gekko & Co 2017-06-02 5304 1075
Gekko & Co 2017-06-11 1075 1062
Gekko & Co 2017-06-12 1062 497