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
Explain triggers?
What are the operating modes in which database mirroring runs?
What do you mean by SQL injection attack?
Describe in brief authentication modes in sql server.
What do you understand by user-defined function in the sql server and explain the steps to create and execute a user-defined function in the sql server?
What is log ldf?
What is a recursive stored procedure in sql server?
What are the different types of join?
Can you give me some DBCC command options?(Database consistency check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.
Explain iaas, paas and saas?
Write an sql query for deleting duplicate rows?
what are the different stages of Report Processing?
What is subquery? Explain the properties of a subquery?
While using a cursor, how can you differentiate between a deleted row and a row that has been inserted with null data values?
What are the different acid properties?