SQL> select dept, MAX(salary)
2 from max_sample
3 group by dept
4 havingcount(*) = count(salary);
DEPT MAX(SALARY)
------------ -----------
管理部 400000
上の SQL は以下のように「意味が正しく、かつ、容易に理解される」ように書くのが望ましい。
SQL> select dept, MAX(salary)
2 from max_sample m1
3 where not exists (
4 select * from max_sample m2
5 where m1.dept = m2.dept and salary IS NULL
6 )
7 group by dept;
DEPT MAX(SALARY)
------------ -----------
管理部 400000