查询大于部门总平均工资部门

select d.*, sum_sal
from dept d, (select sum(sal) sum_sal, deptno from emp group by deptno) e
where d.deptno = e.deptno
  and e.sum_sal > (select avg(sum(sal)) from emp group by deptno);

DEPTNO | DNAME | LOC | SUM_SAL

----------------|-----------------|----------------|-------------

20 | RESEARCH | DALLAS | 10875