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
How to generate create table script on an existing table in ms sql server?
How to create and drop temp table in sql server?
Can we use where clause in union?
Is sql server free?
what is a deadlock? : Sql server database administration
What is difference between inner join and full join?
What is a primary key?
how to create “alternate row colour”?
What is wide table?
Explain iaas, paas and saas?
Do you know what is difference between stored procedure and user defined function?
What is the meaning of lock escalation and why/how to stop this? : sql server database administration
What is spatial and temporal data?
What is DCL?
Tell me in brief how sql server enhances scalability of the database system?