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

How to view the error log for any specific instance? : sql server database administration

989


What are the advantages of stored procedure in sql server?

834


What are indexes in sql?

1177


How many triggers are possible per table?

1040


What is BCP? When does it used in sql server 2012?

1002


Working with TLogs

1786


can an automatic recovery be initiated by a user? : Sql server administration

899


What is multilevel indexing?

882


Can we write trigger for view?

954


Explain sub-query?

902


Explain what are the different index configurations a table can have?

1039


What are the pre-defined functions in the sql server?

1030


What is difference between views and tables?

913


Why do you need a sql server?

1027


What functions can a view be used to performed?

1000