The LAG and LEAD functions add to the ordered analytic capabilities provided by Teradata Database. The LAG function accesses data from a row preceding the current row at a specified offset value in a window group, while the LEAD function returns data from a row following the current row at a specified offset value in a window group.
The functions improve compatibility, and are used with Teradata Database for OLAP and decision support queries. The functions support both Teradata syntax and ANSI syntax to improve data migration.
Benefits
- Provides compatibility with and simplifies data migration from other databases.
- Increases Teradata Database compatibility to the SQL Standard.
Considerations
The LEAD function returns the value displayed in a following row, while the LAG function gives the value from a previous row.
Additional Information
For more information on the LAG/LEAD functions, see Teradata Vantage⢠SQL Functions, Expressions, and Predicates, B035-1145.