如何在SQL Server中的单个查询中找到第五高工资
在SQL Server 2005和2008中,创建排名的子选择查询,然后添加rank = 5的where子句.
select * from ( Select SalesOrderID, CustomerID, Row_Number() Over (Order By SalesOrderID) as RunningCount From Sales.SalesOrderHeader Where SalesOrderID > 10000 Order By SalesOrderID ) ranked where RunningCount = 5