Emp_ID Emp_Name Salary Mgr_ID 1 Aman 45000 NULL 2 Deepak 35000 1 3 Pankaj 32000 1 4 Sapna 25000 1 5 Rajan 50000 NULL 6 Nupur 18000 5 7 Anamika 18000 5 8 Preet 22000 NULL 9 Shalu 27000 NULL 10 Jyoti 12000 9 11 Omesh 25000 9 12 Rakesh 21000 9
SELECT MAX(salary),E1.mgr_id FROM EMP_MGR E1, (SELECT MAX(salary) AS sal,mgr_id FROM EMP_MGR GROUP BY mgr_id ) E2 WHERE E1.salary<e2.sal and="" e1.mgr_id="E2.mgr_id"
Mgr_ID Salary NULL 45000 1 32000 5 18000 9 15000
;WITH CTE ( SELECT salary,mgr_id FROM EMP_MGR GROUP BY mgr_id ) SELECT MAX(SALARY), mgr_id FROM CTE WHERE SALARY <> (SELECT MAX(SALARY) FROM CTE)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)