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

What is GUID in sql server?

1223


What is update_statistics command?

1121


What is the meaning of lock escalation and why/how to stop this? : sql server database administration

1081


What is the difference between web edition and business edition?

113


what are the basic functions for master, msdb, model, tempdb and resource system databases? : sql server database administration

1047


Does partitioning help performance?

997


How do we Backup SQL Azure Data?

108


Can sql servers link to other servers like oracle?

894


How data can be copied from one table to another table?

1004


What is a system database and what is a user database?

1140


What is equi join with example?

1230


How to delete duplicate records based on single column from a table?

1105


Comment,Datatypes are unlimited

2106


What is a not null constraint?

1088


Explain concepts of analysis services?

1014