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
What is buffer cash in sql server?
What is a cube? : sql server analysis services, ssas
What are the basic functions for master, msdb, model, tempdb and resource databases? : SQL Server Architecture
Define left outer join in sql server joins?
Can we do dml on views?
Is it possible to import data directly from t-sql commands without using sql server integration services? If so, what are the commands?
What according to you is the difference between mysql and sql server performance?
What is inline variable assignment?
How to list all stored procedures in the current database using ms sql server?
Can a database be shrunk with users active?
What you can do to delete a table without the delete trigger firing?
Is BCNF better than 2NF & 3NF? Why?
how to determine the service pack currently installed on sql server? : Sql server database administration
What is the most common trace flags used with sql server?
What is exclusive locks?