Lag - Teradata Warehouse Miner

Teradata® Warehouse Miner™ User Guide - Volume 2ADS Generation

Product
Teradata Warehouse Miner
Release Number
5.4.6
Published
November 2018
Language
English (United States)
Last Update
2018-12-07
dita:mapPath
gxn1538171534877.ditamap
dita:ditavalPath
ft:empty
dita:id
B035-2301
Product Category
Software

The LAG function evaluates an expression at a constant offset from the current row. The offset is expressed as the count of rows behind the current row in the sort order of the partition. When dragging a LAG function into a Variable, the following tree element is created.

Variable Creation > Input > Variables: SQL Elements pane - Ordered Analytical Functions> Lag

Teradata Database

The partitioning and sorting syntax is the same as that of other Window functions (there is an OVER clause with PARTITION BY and ORDER BY expressions). In this case, there are also three additional arguments: a required SQL expression, an optional offset (with a default of one), and a default value (with a default of Null). An optional RESET WHEN expression may also be specified as the last item in the Partition Columns folder. A description of this element is given separately in this section.

Row options are not available with the Lag function.

Aster Database

The partitioning and sorting syntax is the same as that of other Window functions (there is an OVER clause with PARTITION BY and ORDER BY expressions). In this case, the ORDER BY clause is required and three additional arguments are required: an SQL expression, an offset, and a default value. As with numbering Window functions, if two or more rows sort as equals (tie) in the sort order, the function arbitrarily sorts the sorted-as-equal rows.