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 / sumit wadhwa

select distinct(a.colname) from table a where &n=(select
count(distinct(b.colname)) from table b where
a.colname<=b.colname);

from this query u can find out Nth MAX in a one query

eg
select distinct(a.sal) from emp a where &n=(select count
(distinct(b.sal)) from emp b where a.sal<=b.sal);

Is This Answer Correct ?    55 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to connect ms access to oracle servers?

1006


What is an anonymous block?

1249


types of indexes and the rationale behind choosing a particular index for a situation.

2510


What is rich query?

981


How to define an external table with a text file?

1069


Explain how are indexes update?

1064


How to define an anonymous procedure with variables?

1159


How to download oracle database 10g xe?

1018


How to best split csv strings in oracle 9i?

1041


Explain the use of record option in exp command.

1006


What is index-organized table in Oracle?

1069


How to create a table index in oracle?

1134


How to run queries on external tables?

1046


Give the different types of rollback segments.

1031


What is a subquery in oracle?

1109