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 do I find the default sql server instance?
What are different types of statement?
What is relationship? What number of sorts of relationship are there?
What is sql injection? How to protect against sql injection attack?
Explain indexed views and partitioned view with their syntax.
Explain how many types of relationship?
Do you know what are pages and extents? : SQL Server Architecture
Detail about the hardware which is supported by SQL server?
How do I get Report Builder to generate a parameter that can be set by users viewing the report?
Write a SQL command to insert and update only a particular field?
Can a table have 2 foreign keys?
Explain triggers in sql?
Suppose you want to implement the one-to-one relationships while designing tables. How would you do it?
How to delete database objects with "drop" statements in ms sql server?
What are sql server procedures?