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

What is the recursive stored procedure in sql server?

527


How to add additional conditions in SQL?

589


How can change procedure in sql server?

524


What is microsoft sql server?

539


What are the database roles? : sql server security

564






what is a deadlock? : Sql server database administration

501


What is change tracking in sql server?

545


What are scalar functions?

507


which backup strategy you are following at ur company

1730


Can you insert NULL in unique column?

628


Explain the concept of recursive stored procedure.

497


What is tablesample?

574


What are the disadvantages of using querystrings to send data from one page to another?

586


Can we use trigger new in before insert?

514


Equi join and non equi join is possible with sql server?

487