select * from hr.employees a
where employee_id in (select employee_id
from hr.employees
where department_id=a.department_id and rownum<3)
order by department_id;
where employee_id in (select employee_id
from hr.employees
where department_id=a.department_id and rownum<3)
order by department_id;
执行的结果应该是一样的
select * from (select t.* ,rank() over(partition by deptno order by sal desc ) rn from emp t ) where rn<3