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

What is buffer cash in sql server?

596


What is a cube? : sql server analysis services, ssas

557


What are the basic functions for master, msdb, model, tempdb and resource databases? : SQL Server Architecture

555


Define left outer join in sql server joins?

544


Can we do dml on views?

543






Is it possible to import data directly from t-sql commands without using sql server integration services? If so, what are the commands?

841


What according to you is the difference between mysql and sql server performance?

550


What is inline variable assignment?

586


How to list all stored procedures in the current database using ms sql server?

628


Can a database be shrunk with users active?

595


What you can do to delete a table without the delete trigger firing?

512


Is BCNF better than 2NF & 3NF? Why?

616


how to determine the service pack currently installed on sql server? : Sql server database administration

555


What is the most common trace flags used with sql server?

506


What is exclusive locks?

531