sql> select deptno,
2 max(decode(seq,1,ename,null)) highest,
3 max(decode(seq,2,ename,null)) second,
4 max(decode(seq,3,ename,null)) third
5 from (
6 select deptno,ename,
7 row_number() over
8 (partition by deptno order by sal desc) seq
9 from emp)
10 where seq <=3 group by deptno
11 /
deptno highest second third
---------- ---------- ---------- ----------
10 king clark miller
20 scott ford jones
30 blake allen turner
|