Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to find the 2nd higgest salary in the column for example
take table name is employee?
And also find bottom 2nd lowest salary ?

Answer Posted / vishnu

Here we can find out 2nd highest salary in many ways,
according to the situation we can select anyone…
1st Type:
select min(esal) from emp where esal in (select top 2 esal
from emp order by esal desc)

2nd Type:
select max(esal) from emp where esal not in(select max(esal)
from emp)

3rd Type:
select max(esal) from emp where esal <(select max(esal) from
emp )

4th Type:
select Max(esal) from EMP a where 2=(select
COUNT(distinct(esal)) from EMP b where a.eSAL<=b.eSAL);

-----------------------------------------

For 2nd Lowest Salary:

-- 1st Type:
select min(esal) from emp where esal > (select min(esal)
from emp)

-- 2nd Type:
select * from emp where esal =
(
select max(esal) from emp where esal in (select top 2 esal
from emp order by esal)
)

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between l1 and l2 cache? : Dot net architecture

883


What is biginteger and when would you use that?

896


What is .net mobile images control. : Microsoft dot net mobile

869


Explain about clr?

985


Differences between VS 2005, 2008 and 2010 ?

948


Explain the types of memory management? : Dot net architecture

893


What is msil, and why should my developers need an appreciation of it if at all?

1071


What are the types of application software?

912


What is a managed code? : Dot net architecture

907


Explain domestic architecture artifacts? : .NET Architecture

892


Why only boxed types can be unboxed?

1034


how to change the application name?

1916


IS IT Possible to inherit the AJAX page from child class which(child) is inherit from page class.Because i should apply some security in child class

1964


what is the method while we are using adapter and dataset ?

1778


What is .net transaction?

871