
- Forum
- Databases
- SQL Server - Give example of mixmize and minimum salary find.
-
Give example of mixmize and minimum salary find.
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.
-
Contributing Member
Re: Give example of mixmize and minimum salary find.
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))
-
Expert Member
Re: Give example of mixmize and minimum salary find.
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;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules