We use SQL LAG() function to access previous rows data as per defined offset value without the use of a self-join. It is a window function available from SQL Server 2012 onwards. It is a useful function in comparing the current row value from the previous row value.
For more articles, you can visit to www.SQLServerLog.com