如何在 SQL Server 中的单个查询中找到第五高的薪水 [英] How to find fifth highest salary in a single query in SQL Server
本文介绍了如何在 SQL Server 中的单个查询中找到第五高的薪水的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 SQL Server 中的单个查询中找到第五高的薪水
How to find fifth highest salary in a single query in SQL Server
推荐答案
在 SQL Server 2005 &2008 年,创建一个排名子选择查询,然后添加一个 where 子句,其中 rank = 5.
In SQL Server 2005 & 2008, create a ranked subselect query, then add a where clause where the rank = 5.
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
这篇关于如何在 SQL Server 中的单个查询中找到第五高的薪水的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文