how to find the second 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);

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is resource db in sql server?

588


How to encrypt data between dialogs?

564


What is trigger in salesforce?

489


Can you roll back the ddl statement in a trigger?

518


Explain few examples of stored procedure over triggers?

512






Does partitioning ssd reduce performance?

486


How to connect a database with sql express.?

560


Describe how to use the linked server?

591


What are the two authentication modes in sql server?

596


What does asynchronous call backs means?

617


What is the difference between dbcc indexdefrag and dbcc reindex?

515


What is the minimum and maximum number of partitions required for a measure group? : sql server analysis services, ssas

592


Explain the creation and execution of a user-defined function in the sql server?

571


What are the different types of replication you can set up in sql server?

523


What is TDS(Tabular Data Stream) Gateway?

99