How to find fifth highest salary in a single query in SQL Server

后端 未结 9 2509
暗喜
暗喜 2020-12-19 08:55

How to find fifth highest salary in a single query in SQL Server

9条回答
  •  北荒
    北荒 (楼主)
    2020-12-19 09:33

    You can try some thing like :

    select salary
    from Employees a
    where 5=(select count(distinct salary)
             from Employees b
             where a.salary > b.salary)
    order by salary desc
    

提交回复
热议问题