Question Detail
How to get top 10 pay of employees table SQL
I want to get details of top 10 paid employees from the Employee Table SQL table? what will be the query?
Thread Reply
Anonymous
- 3 years ago
SELECT *FROM
(
SELECT *FROM emp
ORDER BY Salary desc
)
WHERE rownum <= 3
ORDER BY Salary ;
Anonymous
- 3 years ago
You can try.
SELECT * FROM
(
SELECT EMPLOYEE, LAST_NAME, SALARY,
RANK() OVER (ORDER BY SALARY DESC) EMPRANK
FROM emp
)
WHERE emprank <= 3;
This will give correct output even if there are two employees with same maximum salary
Goal Ploy - Money Management App