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 / ankit nanda

select [Salary],ID from (select [Salary], ROW_NUMBER() over
(order by Employee.SALARY desc)RowNum from [Employee])e
where e.RowNum=2

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you explain important index characteristics?

612


What protocol does sql server use?

602


What are the differences between char and varchar in ms sql server?

660


How to write an inner join with the where clause in ms sql server?

629


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

88






What is resource governor?

630


Define Joins?

686


Is sql server is free?

627


How to provide login information for a new odbc dsn?

615


What are filegroups in sql server?

684


How will you find out if there are expensive SQL statements running or not?

662


Explain different types of locks in sql server.

678


Is it possible to call a stored procedure within a stored procedure?

644


how can you check the level of fragmentation on a table? : Sql server administration

623


What do you mean by an execution plan?

670