how to find nth highest salary
Answer Posted / sanchit dubey
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 order by salary desc ) ' + ' order by salary desc '
SELECT @SQL
EXEC @SQL
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are the results of running this script?
What is collation sensitivity? Explain different types.
What is a trigger in sql server?
What is the index requirement in SQL Azure?
Do you know what are the differences between lost updates and uncommitted dependencies?
What is the difference between char, varchar and nvarchar?
What is the difference between DATETIME2 and DATETIME?
What is the datatype of rowid?
what is unique and xaml nonclustered index
What is entity data services?
How to delete an existing row with delete statements in ms sql server?
What is sql injection? How to protect against sql injection attack?
What is change data capture (cdc) feature?
Where do we use trace frag?
What is difference between rollback immediate and with no_wait during alter database?