Returns the value from n rows before the current row.
Syntax
LAG(expr [, n [, default]]) OVER (w)Example
Enter values below to update the example in real time.
order_month→revenue→prev_revenue→monthly_sales→SELECT order_month, revenue,
LAG(revenue, 1, 0) OVER (ORDER BY order_month) AS prev_revenue
FROM monthly_sales;