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 are the new features of .net 2.0?

953


What is the difference between primary & secondary storage device? : Dot net architecture

945


How resource files are used in .net?

1017


Differnce between managed code and unmanaged code ?

1049


Difference between throw exception and rethrowing ?

2089


What are the important principles of soa (service oriented architecture)?

903


Explain the difference between primary & secondary storage device? : Dot net architecture

932


What is a service class?

993


deference between display and visibility property of CSS

2263


6. Wcf- what is SOA

2333


What are different types that a variable can be defined and their scopes ?

1033


Explain about code access security?

979


how to set the startup position of the form?

1920


what is the difference between running an application with and without debugger?

2078


How can I create a application?

903