LAG
Some parts in the output code are omitted for clarity reasons.
Description
Accesses data from a previous row in the same result set without the use of a self-join starting with SQL Server 2012 (11.x). LAG provides access to a row at a given physical offset that comes before the current row. Use this analytic function in a SELECT statement to compare values in the current row with values in a previous row. (COUNT in Transact-SQL).
Sample Source Pattern
Syntax
Examples
Code:
IN -> SqlServer_01.sql
Result:
Last updated