LEAD
Applies to: CELONIS 4.7
Description
LEAD returns the row that follows the current row by offset number of rows. It is possible to specify a column based ordering and partitioning. Null values are skipped.
Syntax
LEAD ( table.column [, ORDER BY ( order_column [sorting], ... )] [, PARTITION BY ( partition_column, ... )] [, offset ] )
ASC: Ascending order
DESC: Descending order
column: The source column where following rows are taken from.
order_column: Optional order column to specify an sorting.
sorting: Each of these columns can have an optional tag specifying the ordering of the column. Default is ascending:
partition_column: Optional partition column to specify groups in which
LEAD
should operate.offset: The number of non-NULL rows following the current row. The default value is 1.
Ordering
One or more columns can be given to specify an ordering. This tells the LEAD
function what the following element actually is. Optionally every column can be tagged as ascending or descending.
[1] |
[2] |
Partitioning
The partition columns specify groups. The LEAD
function operates independently within every group. This means when an ordering is given it is applied within every group and the last offset
elements in every group have a leading value of null.
[4] |
[5] |
[6]
|
NULL handling
The leading value for a NULL value is the same value as the leading value of the last non-NULL value. The offset parameter counts only non-NULL values.
[7] Example for |
[8] Offset ignores NULL values. |
Examples
[9] Simple example of |
[10] |
[11]
|
[12] It is possible to combine an arbitrary amount of order columns with an arbitrary amount of partition columns.
|
[13] All optional parameters can be combined.
|