Thursday, October 21, 2010

SQL : nth Max Salary

How to get nth Max salary record from employee table;

select ename from emp where sal=(select min(sal) from (select * from emp order by sal desc) where rownum<=n);

Here n denotes number, say if you need to retrieve 22nd Max salary then n=22 here.

No comments:

Post a Comment