Tuesday, August 10, 2010

SQL:List the employees whose salary is greater than their department avg salary

select * from emp e where sal > (select avg(sal) from emp where deptno=e.deptno);

SQL:List the employees who are managers

select * from emp where empno in (select distinct(mgr) from emp);