Monday, December 21, 2009

Find the Nth maximum salary in sql

Find N th maximum salary using rank() function

select * from(
select dense_rank() over(order by salary desc) as rank,name from employee ) as empsalary
where rank=2

No comments: