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
How to use wildcard characters in like operations in ms sql server?
How to create an index on a view?
How can change procedure in sql server?
What will be query used to get the list of triggers in a database?
Explain the purpose of indexes?
What are the 7 disadvantages to a manual system?
What is the library index called?
What are the different types of upgrades that can be performed in sql server?
What is the difference in accessing db between sql server vs sql azure?
What is the difference between clustered and a non-clustered index?
What are indexes in sql?
What is the native system stored procedure to execute a command against all databases?
When is the use of update_statistics command?
Can a synonym name of a table be used instead of a table name in a select statement?
How to drop an existing table with "drop table" statements in ms sql server?