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.
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.