Concept Flow - LAG function for previous row access
Start with ordered rows
For each row
Look at previous row in order
Return previous row's value
If no previous row, return NULL or default
Output current row with previous value
Repeat for all rows
End
The LAG function looks at the previous row's value in a defined order and returns it for the current row, or NULL if there is no previous row.