Example
Select 4th highest salary from table emp
select max(e1.salary) from emp e1
where 4 = (select count(distinct(e2.salary)) from emp e2
where e1.salary >= e2.salary)
where 4 = (select count(distinct(e2.salary)) from emp e2
where e1.salary >= e2.salary)
You can pass any number instead of 4 to get Nth highest figure
No comments:
Post a Comment
Note: only a member of this blog may post a comment.