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 use an oracle sequence generator in a mapping?

1131


What is the difference between $oracle_base and $oracle_home?

1136


How to find out what oracle odbc drivers are installed?

1092


How to test null values?

1156


How to check the oracle tns settings?

1088


Explain an extent?

1155


What are the general rules on data consistency?

1062


what is normalisation?what are its uses?

2329


How remove data files before opening a database?

1135


How to do paging with oracle?

1050


What is a snapshot in oracle database?

1072


Explain a synonym?

1088


What is connection pooling in oracle?

1018


What is index-organized table in Oracle?

1118


21. Using a set operator, display the client number of all clients who have ever placed an order and whose whose name does not contain the string Sm.

2166