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

what is syntex second or third highest salary.


thanks & Regards
Dhirendra sinha

Answer Posted / satish

select max(sal) from emp e1 where 1< (select count(distinct sal) from emp e2 where e1.sal <= e2.sal)

To make it generic if u want N'th highest salary;

select max(sal) from emp e1 where (N-1)< (select count(distinct sal) from emp e2 where e1.sal <= e2.sal)

And to get the N'th min sal :

select min(sal) from emp e1 where (N-1)< (select count(distinct sal) from emp e2 where e1.sal >= e2.sal)

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do we synchronize On-Premise SQL server with SQL Azure?

120


Can we add an identity column to decimal datatype?

963


Can we insert data into view sql server?

891


Can you explain about buffer cash and log cache in sql server?

911


How connect excel to sql server?

938


How to assign new column names in a view?

874


What is indexing explain it with an example?

950


What are orphan records?

894


What are group functions in query statements in ms sql server?

963


How do I setup a sql server database?

1021


Is sql server 2016 free?

888


What is the difference between value type and reference type?

881


How do I open a .db file?

985


You have several tables, and they are joined together for querying. The tables contain both clustered indexes and non clustered indexes to optimize performance, how should you distribute the tables and their indexes onto different file groups?

958


What is side by side migration in sql server?

1042