How to find out the top 5 earners of company based on emp dept table?

Oracle Apps Interview QuestionsCategory: SQLHow to find out the top 5 earners of company based on emp dept table?
Questions Master asked 9 years ago

How to find out the top 5 earners of company based on emp dept table?

1 Answers
Shailender Thallam Staff answered 9 years ago

SELECT DISTINCT ename,sal
from emp e
WHERE 4>=
  (SELECT COUNT(DISTINCT sal) FROM emp a WHERE a.sal>=e.sal
  )
ORDER BY sal DESC;