Lag Function: Access data in a previous row in the same result set without having to join the table to itself.
How to use the SQL LAG window function to compare current and previous row values, with practical query and table output.
How to use the SQL LAG window function to compare current and previous row values, with practical query and table output.