Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How do I find the default sql server instance?

946


What are different types of statement?

1022


What is relationship? What number of sorts of relationship are there?

1143


What is sql injection? How to protect against sql injection attack?

1003


Explain indexed views and partitioned view with their syntax.

1147


Explain how many types of relationship?

1034


Do you know what are pages and extents? : SQL Server Architecture

996


Detail about the hardware which is supported by SQL server?

1067


How do I get Report Builder to generate a parameter that can be set by users viewing the report?

154


Write a SQL command to insert and update only a particular field?

1118


Can a table have 2 foreign keys?

910


Explain triggers in sql?

957


Suppose you want to implement the one-to-one relationships while designing tables. How would you do it?

959


How to delete database objects with "drop" statements in ms sql server?

1094


What are sql server procedures?

989