Tuesday, December 6, 2011

SQL: Finding the Nth maximum

1. List of the 10 employees with the highest salary. (ONLY the top 10)
2  The employee with the 5th highest salary.

To find  nth maximum salary from a table called emp

select * from emp e where &n = ( select count(distinct(salary) from emp where e.sal <= sal)


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.