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 Service Broker in sql server 2012?
How do you debug a procedure in sql server?
what is a transaction? : Sql server database administration
How to return the top 5 rows from a select query in ms sql server?
In which sql server version report builder introduced?
how to use DTS package in 2000,2005,2008 in sql server
What is query cost in sql server?
Can you explain powershell included in sql server 2008?
what are user defined datatypes? : Sql server database administration
How can you find out which stored procedures are recompiling?
What are the rules to use the rowguidcol property to define a globally unique identifier column?
what changed between the previous version of sql server and the current version? : Sql server database administration
What command must you use to include the not null constraint after a table has already been created?
What is data compression?
Explain triggers in sql?