select * from (select e1.empno, e1.ename, e1.sal (select avg(sal) from emp e2 where e2.deptno = e1.deptno) as avg from emp e1) t where t.sal>t.avg