Hello friends,
Can any one give me the sql query which find the min and max salary find in the table. also tell me that how to find any 2nd and 3rd greatest salary in the given table.
Printable View
Hello friends,
Can any one give me the sql query which find the min and max salary find in the table. also tell me that how to find any 2nd and 3rd greatest salary in the given table.
Replace "n" with the no. u want to get the nth highest salary.
select *
from emp e1
where ( n =
( select count ( distinct ( e2.sal ) )
from emp e2
where e2.sal >=e1.sal))
You may get the result using the following query also
select level, max('col_name') from my_table
where level = '&n'
connect by prior ('col_name') > 'col_name')
group by level;