How to find third or nᵗʰ maximum salary from salary table?

后端 未结 30 733
醉酒成梦
醉酒成梦 2020-11-30 16:30

How to find third or nth maximum salary from salary table(EmpID, EmpName, EmpSalary) in optimized way?

30条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 17:27

    Third or nth maximum salary from salary table without using subquery

    select salary from salary
       ORDER   BY salary DESC
       OFFSET  N-1 ROWS
       FETCH NEXT 1 ROWS ONLY
    

    For 3rd highest salary put 2 in place of N-1

提交回复
热议问题