LAG

A window function returning a value from an earlier row in the window partition.

What is LAG in a relational database?

LAG — A window function returning a value from an earlier row in the window partition.

SELECT ordered_on,
       LAG(total_amount) OVER (ORDER BY ordered_on) AS previous_total
FROM purchase_order;

Level: Journeyman · More Database terms at this level

Updated