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
What are cascading parameters in ssrs reports?
What is perspective, have you ever created perspective? : sql server analysis services, ssas
What command do we use to rename a database?
Is null in sql server?
How can you list all the table constraints in a database?
What can be used instead of trigger?
what is bit datatype? : Sql server database administration
what is bit datatype and what's the information that can be stored inside a bit column? : Sql server database administration
What is the maximum length of an alert name?
What are click through reports?
How to make conditional sum in ssrs?
How do I create a stored procedure in sql server?
How sql server enhances scalability of the database system?
What are triggers? How many triggers you can have on a table? How to invoke a trigger on demand?
Suppose you want to implement the one-to-one relationships while designing tables. How would you do it?