I Have Employee table having column name as ID,SALARY
how to get second max salary from employee table with id
ex
ID SALARY
1 20000
7 37000
2 5000

Answer Posted / sudip mondal

select top 1 from employee where ID in (select top2 ID from
employee order by Salary desc) order by Salary asc

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define cursor locking

550


How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?

584


What is join and name different type of joins?

584


What is the difference function and stored procedure?

565


How would you choose between a clustered and a non-clustered index?

545






What is log shipping? Can we do logshipping with SQL Server 7.0 ?

578


Tell me what is the difference between locking and multi-versioning?

579


What is @@rowcount in sql?

566


Explain what are the database objects? : SQL Server Architecture

571


How to convert a numeric expression from one data type to another?

503


What are data regions?

92


Do you know what is lock escalation?

582


What is the difference between the application object and session object?

600


What is difference between equi join and inner join?

482


How to change parameter value inside the report?

104