sql SQL Server 2012 TSQL新函数LAG,LEAD,FIRST_VALUE和LAST_VALUE
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql SQL Server 2012 TSQL新函数LAG,LEAD,FIRST_VALUE和LAST_VALUE相关的知识,希望对你有一定的参考价值。
SELECT [Name]
,[Subject]
,[Score]
,LAG(Score, 1, 0) Over (Partition By Name Order By Subject) As [LagValue]
,LEAD(Score, 1, 0) Over (Partition By Name Order By Subject) As [LeadValue]
,FIRST_VALUE(Score) Over (Partition By Name Order By Subject) As [FirstValue]
,LAST_VALUE(Score) Over (Partition By Name Order By Subject) As [LastValue]
FROM [Test].[dbo].[Score]
以上是关于sql SQL Server 2012 TSQL新函数LAG,LEAD,FIRST_VALUE和LAST_VALUE的主要内容,如果未能解决你的问题,请参考以下文章