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 / 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


Please Help Members By Posting Answers For Below Questions

Explain the advantages of merge replication?

959


What is the difference between createstatement and preparedstatement?

952


Explain what are the basic functions for master, msdb, model, tempdb databases?

988


What are data driven subscriptions?

115


What are the advantages of sql azure?

140


What is an execution plan?

1160


What is subquery in sql?

1075


Define outer join?

1007


What is the use of “join” in sql server?

1109


Is it possible for a stored procedure to call itself or recursive stored procedure?

955


What is a field in a table?

1047


How to compare the top two records using sql?

1354


What is @@rowcount in sql?

1014


What is filter index?

961


What is usually the first word in a sql query?

1142