标签: sql sql-server sql-server-2005 tsql sql-server-2008
如何在不使用MS SQL中的任何子查询的情况下找到第N个最高工资?
答案 0 :(得分:7)
;WITH cte1 AS ( SELECT ROW_NUMBER() OVER(ORDER BY SALARY DESC) AS RN, * FROM Salaries ) SELECT * FROM cte1 WHERE RN = 5 <-- Nth highest
答案 1 :(得分:0)
查看row_number函数。 :)
http://msdn.microsoft.com/en-us/library/ms186734.aspx