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 / radhakrishnan vaithilingam

SELECT TOP 1 id.salary
FROM (SELECT TOP 2 id,salary
FROM employee
ORDER BY salary DESC )a
ORDER BY a.salary ASC

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is replication with database mirroring? : sql server database administration

532


What are the authentication modes in sql server? How can it be changed?

602


What are the 7 disadvantages to a manual system?

515


Can you explain what are various ways to enhance the ssrs report?

583


What is the synonym of join?

521






Why I have to use stored procedures?

598


What do you mean by SQL injection attack?

620


Does sql server use t sql?

526


What is triggers in ms sql server?

640


How do I clean up sql server transaction log?

572


What is schemabinding a view?

532


How is sql server used?

547


What are the advantages of using cte?

555


How to resolve the orphan use problem? : sql server security

527


What is sql server database?

500