How to find out last 5 (least) earners of the company.?

Oracle Apps Interview QuestionsCategory: SQLHow to find out last 5 (least) earners of the company.?
Questions Master asked 9 years ago

bottom 5 earners of the company in

1 Answers
Shailender Thallam Staff answered 9 years ago

SELECT DISTINCT sal
FROM emp e
WHERE 5>=
  (SELECT COUNT(DISTINCT sal) FROM emp a WHERE a.sal<=e.sal
  )
ORDER BY sal DESC;