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
What is a functions and types in sql server?
What are tables in sql server?
What is table valued function and scalar valued functions?
What is create statement?
What happens if the update subquery returns multiple rows in ms sql server?
What is the beast way to write CTE in SQL Server ?
You accidentally delete the msdb database what effect does this have on your existing sql databases, and how do you recover?
How adventureworkslt tables are related?
What is a View ? Can we insert, Update and delete a view?
What programming language would you use to create embedded functions in ssrs?
What is a unique index?
Explain Normalization and DE normalization
How to concatenate two binary strings together?
What are the main differences between #temp tables and @table variables and which one is preferred?
Which autogrowth database setting is good?