How to obtain employees who earn sal greater than avg sal in the given deptment in classic emp, dept tables

Showing Answers 1 - 2 of 2 Answers

Yoga

  • Sep 26th, 2007
 

Select ename, deptno, sal
from emp where sal > (select avg (sal) from emp) group by ename, deptno, sal

  Was this answer useful?  Yes

SELECT
  e.EMPNO,
  e.ENAME,
  e.deptno,
  e. SAL,
  e1.avg_sal
FROM
  emp e,
  (SELECT AVG(sal) avg_sal,
  deptno FROM emp  GROUP BY deptno ) e1
WHERE
  e.deptno =e1.deptno AND
  e.sal >e1.avg_sal;

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions