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

前端 未结 11 1865
孤独总比滥情好
孤独总比滥情好 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:56

    select min(salary),deptno from
    (SELECT distinct top 2 salary,deptno from table ORDER BY salary DESC)
    as  a 
    group by deptno
    

提交回复
热议问题