我想在 SQL Server 中编写这个查询
from (
select DISTINCT salary
from employee
order by salary desc
)
where rownum = 3;
最佳答案
参见 ROW_NUMBER() :
例如,
WITH EmployeeSalary AS
(
select salary,
ROW_NUMBER() OVER (order by salary desc) AS 'RowNumber'
FROM employee
group by salary --you can't use DISTINCT because ROW_NUMBER() makes each row distinct
)
SELECT *
FROM EmployeeSalary
WHERE RowNumber = 3;
关于sql - 需要有关 SQL Server 查询的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5994083/