Geeks Talk

Prepare for your Next Interview




Give example of mixmize and minimum salary find.

This is a discussion on Give example of mixmize and minimum salary find. within the SQL Server forums, part of the Databases category; 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 ...


Go Back   Geeks Talk > Databases > SQL Server

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-06-2008
Contributing Member
 
Join Date: Feb 2008
Location: Pune
Posts: 71
Thanks: 34
Thanked 5 Times in 5 Posts
bhushanbhangale is on a distinguished road
Exclamation 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.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-06-2008
Contributing Member
 
Join Date: Sep 2007
Posts: 36
Thanks: 1
Thanked 3 Times in 3 Posts
ssuvi is on a distinguished road
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))
Reply With Quote
The Following User Says Thank You to ssuvi For This Useful Post:
  #3 (permalink)  
Old 03-06-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
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;
Reply With Quote
Reply

  Geeks Talk > Databases > SQL Server


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
How to Find minimum number of test cases for particular case pradeepk Testing Issues 5 02-04-2008 02:37 AM
Minimum requirement for creating matrix report Geek_Guest Oracle 2 07-30-2007 09:07 AM
employee name and salary from employee and salary table Himu SQL 1 07-04-2007 05:34 AM
Can you find the letter…Give a Try blenda Brainteasers 1 08-29-2006 03:49 AM
Give all possible ways for achieving this in Minimum time Remasri Brainteasers 1 08-25-2006 04:24 PM


All times are GMT -4. The time now is 03:49 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved