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

Explain a .net mobile example with details? : Microsoft dot net mobile

478


Can you explain update progress control?

523


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

508


Explain about validation?

605


What is textbox control of .net mobile? : Microsoft dot net mobile

615






Explain How to improve the cache performance? : Dot net architecture

518


define cache memory? : Dot net architecture

539


Can you explain atlasuiglitz library?

528


Explain the types of memory management? : Dot net architecture

503


What is biginteger and when would you use that?

533


What is the procedure on hardware that converts the ascii value to binary? : .NET Architecture

538


What is the access level of the visibility type internal?

602


What size is a .net object?

635


What is .net viewstate?

494


Explain cache memory? : Dot net architecture

538