how to find nth highest salary

Answer Posted / jeevan

CREATE TABLE
[dbo].[Table_1]([ID] [int] NOT NULL,[SAL] [int] NULL)

//N=9
SELECT TOP 1 * FROM dbo.Table_1
WHERE ID NOT IN (SELECT TOP 8/*N-1*/ ID FROM dbo.Table_1
ORDER BY SAL DESC)
ORDER BY SAL DESC

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to trace the traffic hitting a sql server? : Sql server database administration

1146


Define right outer join?

552


Explain security with sql azure?

161


What is a database table?

533


Do you know what is xpath?

561






What programming language would you use to create embedded functions in ssrs?

122


What is the difference between varchar and varchar(max) datatypes?

567


What is the architecture of ms sql reporting service?

530


What is delete query?

529


What are various ways to enhance the ssrs report?

542


If you want to send some data from access database to sql server database. What are different component of ssis will you use?

512


How display code or Text of Stored Procedure using Sql query in Sql Server ?

615


How to encrypt data between dialogs?

580


Why I am getting "the microsoft .net framework 2.0 in not installed" message?

519


Explain triggers in sql?

558