发布网友 发布时间:2022-04-22 20:49
共2个回答
热心网友 时间:2022-05-05 21:56
select deptno 部门,max(decode(a,'1',ename)) 第一名,max(decode(a,'2',ename)) 第二名,max(decode(a,'3',ename)) 第三名 from (select ename,sal,deptno, row_number() over(partition by deptno order by sal desc) a from emp ) group by deptno;
热心网友 时间:2022-05-05 23:14
select deptno 编号,max(decode(r,'1',ename)),max(decode(r,'2',ename)),max(decode(r,'3',ename)) from (select deptno,ename,row_number() over(PARTITION BY deptno ORDER BY sal desc) r from emp ) group by deptno;