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 happens when converting big values to integers?
Can I save my report as html, excel or word? : sql server management studio
Is profiler the only tool that has the ability to audit and identify ddl events? : sql server security
Write a sql query to display the current date?
What changes in the front end code is needed if mirroring is implemented for the high availability? : sql server database administration
How is SQL Azure different than SQL server?
After creating the cube, if we added a new column to the oltp table then how you add this new attribute to the cube? : sql server analysis services, ssas
What do you mean by tablesample?
What are the different types of Indexes available in SQL Server?
What is function of ROLLUP ?
What are functions in the sql server?
How do I change my passwords (database, LDAP, and so on) without causing an outage?
What is policy based management (pbm)? : sql server database administration
How to start and end transact-sql statements?
What is wrong with sql server client libarary dll, ntwdblib.dll?