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

Query to get max and second max in oracle in one query ?

Answer Posted / bhanu yadav

For Nth Max.

select distinct a.sal from emp a where &N= (select count
(distinct b.sal) from emp b where b.sal>=a.sal)

For Nth Min.

select distinct a.sal from emp a where &N= (select count
(distinct b.sal) from emp b where b.sal<=a.sal)

Is This Answer Correct ?    9 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to execute a stored procedure in oracle?

1080


Explain the use of Merge statement in oracle 11g

1025


What is the difference between a user and a schema in oracle?

1029


How to select an oracle system id (sid)?

1059


How to find out what oracle odbc drivers are installed?

1038


What is java oracle used for?

1019


State and explain about oracle instance?

991


What are the most common interview questions on ETL Testing for experience?

1137


What is index in Oracle?

1068


is there a tool to trace queries, like profiler for sql server?

1139


What is a trace file and how is it created in oracle?

1048


What are the restrictions in a oracle read only transaction?

1028


How to define a variable of a specific record type?

1069


How to resolve name conflicts between variables and columns?

1026


What language does oracle use?

1096