nPath Function LAG Expression Syntax | Teradata Vantage - 17.05 - LAG Expression Syntax - Teradata Database

Teradata Vantage™ - Advanced SQL Engine Analytic Functions

prodname
Advanced SQL Engine
Teradata Database
vrm_release
17.00
17.05
created_date
June 2020
category
Programming Reference
featnum
B035-1206-170K
{ current_expr operator LAG (previous_expr, lag_rows [, default]) |
  LAG (previous_expr, lag_rows [, default]) operator current_expr }

where:

  • current_expr is the name of a column from the current row (or an expression operating on this column).
  • operator is either >, >=, <, <=, =, or <>
  • previous_expr is the name of a column from a previous row (or an expression operating on this column).
  • lag_rows is the number of rows to count backward from the current row to reach the previous row. For example, if lag_rows is 1, the previous row is the immediately preceding row.
  • default is the value to use for previous_expr when there is no previous row (that is, when the current row is the first row or there is no row that is lag_rows before the current row).