Scenario:
Find the
3rd MAX & MIN salary in the emp table
Solution:
Max -
select
distinct sal from emp e1 where 3 =
(select
count(distinct sal) from emp e2 where e1.sal <= e2.sal);
Min -
select
distinct sal from emp e1 where 3 =
(select
count(distinct sal) from emp e2 where e1.sal >= e2.sal);
Comments
Post a Comment