我希望在SQL Server中编写此查询
from (
select DISTINCT salary
from employee
order by salary desc
)
where rownum = 3;
我希望在SQL Server中编写此查询
from (
select DISTINCT salary
from employee
order by salary desc
)
where rownum = 3;
查看 ROW_NUMBER():
E.g.,
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;
SELECT DISTINCT salary
FROM employee
WHERE rownum = 3
ORDER BY salary
这些大写字母是可选的。rownum 是 employee 表中的一列,还是你只想返回第三行?
{}
)以使其格式化和语法高亮! - marc_s