How to display the names of the employees who earn highest salary in their respective departments?

Oracle Apps Interview QuestionsCategory: SQLHow to display the names of the employees who earn highest salary in their respective departments?
Questions Master asked 9 years ago

How to display the names of the employees who earn highest salary in their  respective departments?

1 Answers
Shailender Thallam Staff answered 9 years ago

SELECT ename,
  sal,
  deptno
FROM emp
WHERE sal IN
  (SELECT MAX(sal) FROM emp GROUP BY deptno
  );