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

'top' will fetch only top most : ie top 5 means it will
fetch first 5 rec. After fetching rec only 'order by' is
done ie sorting is done after fetching. therefore using
'top' and 'order by' alone wont get max or min value. for
that we have to use 'distinct' before 'top' (which will sort
the records before fetching).

select top 1 salary from employee where salary in (select
distinct
top n salary from employee order by salary desc)

Is This Answer Correct ?    7 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we use where clause with group by?

904


Explain having clause?

969


How to name query output columns in ms sql server?

968


What is difference between rollback immediate and with no_wait during alter database?

1092


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

1140


What are the types of joins in sql?

1128


What is the difference between varchar and varchar(max) datatypes?

1078


What are cursors? Explain the different types of cursors Enlist a few disadvantages of cursors.

1269


What does <> symbol mean?

975


Name few endpoints exposed by ssrs 2012?

355


What is the difference between migration and upgradation in sql server?

1097


What is checkpoint in sql server?

1164


How to convert character strings into numeric values?

1097


How do you test your database? : sql server database administration

1023


How global temporary tables are represented and its scope?

977