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


Please Help Members By Posting Answers For Below Questions

What do I need to start working with sql studio? : sql server management studio

592


What is NOT NULL Constraint in sql server 2012?

600


What is etl - extraction, transformation, and loading?

522


Explain an incremental backup?

592


What is the difference between count () and rowcount ()?

521






Can you pass expressions to stored procedure parameters?

504


What do you mean by a dependent functionality in a build?

661


What is replication with database mirroring? : sql server database administration

531


how you can configure a running aggregate in SSRS?

112


what is the information that can be stored inside a bit column? : Sql server database administration

522


Explain what is the difference between union and union all?

550


How can you ensure that the database and sql server based application perform well?

635


What are parameterized reports? What are cascading parameters in ssrs reports?

100


How efficient you are in oracle and SQL server?

642


Can a unique index be created on a column, which contains null?

523