Thursday, September 26, 2019

Oracle salary of emp which > salary of his manager

select e.empno,e.ename,e.sal from emp e
where e.sal > (select m.sal from emp m where m.empno =(select mgr from emp mg where e.empno = mg.empno) and m.empno = e.mgr)
SELECT
*
FROM
EMP EM
WHERE
SAL  > (SELECT SAL FROM EMP WHERE EMPNO  = EM.MGR)

--------------
SELECT E.SAL,E.EMPNO,E.ENAME,M.SAL MSAL
  FROM EMP E,EMP M
  WHERE M.EMPNO = E.MGR
  AND E.SAL > M.SAL

No comments:

Post a Comment