how to find nth highest salary
Answer Posted / vidit
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 ? | 4 Yes | 1 No |
Post New Answer View All Answers
mention different types of relationships in the dbms?
What is a periodical index?
What happens if ntwdblib.dll is missing on your machine?
How to disable triggers using "disable trigger"?
What is a rollup clause?
What is the web service used for reporting services?
How to convert numeric expression data types using the cast() function?
What is replication with database mirroring? : sql server database administration
What is lock escalation? : sql server database administration
What are the disadvantages of indexes?
How do you maintain database integrity where deletions from one table will automatically cause deletions in another table?
What do you mean by 'normalization'?
How to return the top 5 rows from a select query in ms sql server?
What are Row versions of DataRow?
Explain what role entity and relationship play in an ER diagram.