from the table display the 2nd highest salary?
and also the least 2nd salay?

Answer Posted / prasanthi

Query for Getting 2nd least salary (replace 2 with any
number so that you will get any least salary:

select max(Salary) from Employee
where Salary in
(select distinct top 2 Salary from dbo.Employee order by
Salary asc)

Query for Getting 2nd Height salary (replace 2 with any
number so that you will get any least salary:

select min(Salary) from Employee
where Salary in
(select distinct top 2 Salary from dbo.Employee order by
Employee desc)

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different types of sub-queries?

598


Explain system rowset functions?

554


Detail about query optimizer?

609


Do you know nested transaction?

506


Do you know what are pages and extents? : SQL Server Architecture

548






What is self contained multi valued query?

556


What is the default schema of your login session in ms sql server?

586


Can you explain the disadvantages/limitation of the cursor?

503


Does full backup break log chain?

543


What are different types of subquery?

717


List layers of abstraction microsoft architectured to provide relational db through cloud platform ?

161


What security features are available for stored procedure?

589


Can two tables share a primary key?

514


How can we migrate from SQL server to SQL Azure?

92


Distinguish between commit and rollback?

547