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


Please Help Members By Posting Answers For Below Questions

Can two tables have the same primary key?

558


what is the difference between a primary key and a unique key? : Sql server database administration

523


What is the use of for clause?

576


What are various limitations of the views?

607


What is the difference between a check constraint and a rule?

618






How to name query output columns in ms sql server?

531


Is there any difference between the primary key and unique key?

565


List the various tools available for performance tuning?

480


What is sqlservr.exe - process - sql server (sqlex?press)?

594


Explain full-text indexing?

510


what are questions asked in TCS for database tester (sqlserver)for 2-3 exp?

5495


What is snapshot report?

129


How to create a dml trigger using create trigger statements?

550


What is subquery in sql?

566


What does COMMIT command do?

622