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 / chan

SELECT ID, SALARY FROM
(
SELECT ID, SALARY, ROW_NUMBER() OVER (ORDER BY SALARY) AS RN
FROM EMPLOYEE
)
WHERE RN = 1

(YOU CAN CHANGE VALUE OF RN = ANY NUMBER AND YOU WILL GET
THAT VALUE)

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to use wildcard characters in like operations in ms sql server?

809


How to create an index on a view?

747


How can change procedure in sql server?

712


What will be query used to get the list of triggers in a database?

746


Explain the purpose of indexes?

723






What are the 7 disadvantages to a manual system?

684


What is the library index called?

775


What are the different types of upgrades that can be performed in sql server?

908


What is the difference in accessing db between sql server vs sql azure?

166


What is the difference between clustered and a non-clustered index?

771


What are indexes in sql?

771


What is the native system stored procedure to execute a command against all databases?

717


When is the use of update_statistics command?

738


Can a synonym name of a table be used instead of a table name in a select statement?

770


How to drop an existing table with "drop table" statements in ms sql server?

729