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 are the differences between having and where clause.
what is a correlated sub-query? : Sql server database administration
Does full backup break log chain?
You want to use a perspective in an mdx query. How do you select the perspective?
Which command is used for user defined error messages?
How to connect to SQL Azure Database by using sqlcmd?
What are the differences between “row_number()”, “rank()” and “dense_rank()”?
What is cursors?
What is a with(nolock)?
What are pages and extents? : SQL Server Architecture
How to delete duplicate rows?
Where are stored procedures in sql server?
What is the difference function and stored procedure?
What is unpivot?
Define candidate key, alternate key, and composite key.