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

How do indexes help, types?

628


What extended events?

643


What is log ldf?

638


Can we run Reporting Services with SQL Server express edition, which is a free version of SQL Server?

88


what is a check constraint?

735






How to receive output values from stored procedures?

588


Does any body please help me what question's have asked for SSRS in the interview?

1757


What is difference between joins and subqueries?

622


Which sql server table is used to hold the stored procedure scripts?

703


Explain foreign key in sql server?

656


What is serializable?

748


What is instead of dml trigger?

695


Which autogrowth database setting is good?

703


How to read data in a table with "select" statements?

635


Can We Use Data-grids For Our Report In Ssrs?

153