如何获得每个部门2名员工的最高工资

时间:2017-04-10 06:38:27

标签: sql oracle oracle10g top-n

如何获得与员工相关的每个部门的2名员工的最高薪水?

1 个答案:

答案 0 :(得分:2)

像这样的东西

select * from (
select employee_id,row_number() over (partition by department 
  order by salary desc) as rno 
 from employee
) t
where rno<=2