SQL> select * from emp01;
EMP_ID DEPT_ID EMP_NAME YEARS SALARY ----- ----- ---------- ---------- ---------- E01 D01 なまえ1 3 150 E02 D02 なまえ2 7 200 E03 D03 なまえ3 7 300 E04 D02 なまえ4 7 400 E05 D03 なまえ5 3 500 E06 D02 なまえ6 3 600
SQL> select 2 max( salary ) keep ( dense_rank last order by years ) as salary 3 from emp01;
SALARY ---------- 400
SQL> select 2 dept_id, 3 max( salary ) keep ( dense_rank last order by years ) as salary 4 from emp01 5 group by dept_id;
DEPT_ID SALARY ------ ---------- D01 150 D02 400 D03 300