how to get second highest salary department wise without using analytical functions?

前端 未结 11 1864
孤独总比滥情好
孤独总比滥情好 2021-01-06 03:08

Suppose we have 3 employees in each department.we have total 3 departments . Below is the sample source table

Emp deptno salary
A    10     1000
B    10              


        
11条回答
  •  迷失自我
    2021-01-06 03:59

    You can find 2nd highest salary something like this:

    select max(a.Salary),a.Deptno from Employee a join (select MAX(salary) salary 
    from Employee group by Deptno) b on a.Salary < b.salary group by a.Deptno
    

    And no MAX() is not an analytic function.

    Reference

提交回复
热议问题