how to find nth highest salary
Answer Posted / mayur
DECLARE @SQL VARCHAR(2000), @N INT
SET @N = 5
SET @N = @N - 1
SET @sql = 'select top 1 salary from ABC where salary not
in ( SELECT TOP ' + CAST(@n AS VARCHAR(100)) + ' salary
FROM ABC ) '
SELECT @SQL
EXEC (@SQL)
Is This Answer Correct ? | 24 Yes | 71 No |
Post New Answer View All Answers
Explain difference between cross join and full outer join?
Can a stored procedure call itself or a recursive stored procedure? How many levels of sp nesting is possible?
What is a transactions?
How can I add Reporting Services reports to my application?
Explain four layers of abstraction microsoft architectured?
What is the difference between a local and a global temporary table?
What are the properties and different types of sub-queries?
How to transfer data from a cursor to variables with a "fetch" statement?
What is a fill factor?
What is a primary key?
How to restore performance issues and how to check?
Why normalization is used?
We need to perform what steps in the following order to work with a cursor?
what's the difference between delete table and truncate table commands? : Sql server database administration
What is auditing in sql server?