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 you drop an index?

924


Your sql server is running out of disk space. You notice that there are several large files with ldf extensions what are these files?

1189


What are the drawbacks of reporting in ssrs?

149


Explain an incremental backup?

1002


Can a trigger be created on a view?

956


What do you mean by normalisation?

1043


Can truncate be rolled back?

946


What are the built in functions in sql server?

985


Why we use functions in sql server?

1078


What is the difference between insensitive and scroll cursor?

1160


What is the difference between deallocate cursor and close cursor?

1260


What is CTE in SQL

945


What are sql server procedures?

982


What is a linked server in sql server?

1075


Explain what you mean by 3 tier architecture.

1077