How to get 1st, 2nd, 3rd, 4th, nth topmost salary from an Employee table
The following solution is for getting 5th highest salary from Employee table ,SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 5 salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
If you want to retrieve a nth Maximum value then use nth value instead of 5 and enjoy!!!!!!!
Cheers
5 comments:
Hi Guru,
Nice Post,
Keep writing useful post like this.
Thanks & Regards
Ramani Sandeep
Thank you very much dear
what is the use of 'a' in your query
what is the "a"
"a" is an alias for temporary data.
Post a Comment