Avi*_*are 3 sql t-sql sql-server-2005
我想在SQL Server中编写此查询
from (
select DISTINCT salary
from employee
order by salary desc
)
where rownum = 3;
Run Code Online (Sandbox Code Playgroud)
请参阅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;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
68 次 |
最近记录: |