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 / bobby
SELECT sm ,custid ,ordyear,amount FROM
(SELECT sm ,custid ,ordyear,amount,Rank() OVER (ORDER BY
amount desc)as Rank
FROM dbo.OrderCust)p where rank=2
This is used to select all the rows having the second max
salary.
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Can two tables have the same primary key?
what is the difference between a primary key and a unique key? : Sql server database administration
What is the use of for clause?
What are various limitations of the views?
What is the difference between a check constraint and a rule?
How to name query output columns in ms sql server?
Is there any difference between the primary key and unique key?
List the various tools available for performance tuning?
What is sqlservr.exe - process - sql server (sqlex?press)?
Explain full-text indexing?
what are questions asked in TCS for database tester (sqlserver)for 2-3 exp?
What is snapshot report?
How to create a dml trigger using create trigger statements?
What is subquery in sql?
What does COMMIT command do?