[SQL Server] RANK (Transact-SQL) 返回结果集的分区内每行的排名
语法:
1 RANK ( ) OVER ( [ < partition_by_clause > ] < order_by_clause > )
示例:
1 Select * From ElectricBP
2 Where RowID in (Select RowID From
3 (
4 Select RowID,RANK() Over(PARTITION BY InsureNo Order By OperateTime Desc) As [RANK] From ElectricBP
5 ) T Where [RANK]=1)
2 Where RowID in (Select RowID From
3 (
4 Select RowID,RANK() Over(PARTITION BY InsureNo Order By OperateTime Desc) As [RANK] From ElectricBP
5 ) T Where [RANK]=1)