From SQL Server 2012, new built-in analytic functions are introduced, using that we can easily access subsequent/previous row in the same result set without the use of a self-join and first/last value in an ordered set of values.
In this post, let us see some examples for LEAD(), LAG(), FIRST_VALUE() and LAST_VALUE()
In this post, let us see some examples for LEAD(), LAG(), FIRST_VALUE() and LAST_VALUE()