Skip to content

Home / Glossary / LAG / LEAD

SQL

LAG / LEAD

Window functions that look at the previous / next row.

LAG(col, n) returns the value n rows before the current row; LEAD(col, n) looks n rows ahead. Essential for computing period-over-period changes in financial time series without a self-join.

Example

LAG(close, 1) OVER (PARTITION BY ticker ORDER BY date)

Practise LAG / LEAD hands-on — free, in your browser

Related terms