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

What are the extensions used by oracle reports?

1085


What is the usage of merge statement?

1202


how to handle exceptions in post production

1482


What are the different types of trigger and explain its various uses and functions?

1166


What is the difference between sharding and replication?

1131


What are the different types of synonyms?

1197


How different is ms access and oracle?

1086


Is oracle a programming language?

1035


Does oracle partitioning improve performance?

1051


What is a partition in oracle?

1202


How do we get field detail of a table?

1125


Explain the use of rows option in imp command.

1130


What is the disadvantage of User defind function?

2340


What are a query and state the different types of queries and their uses?

1062


how to code performance tuning of oracle PL/SQL? can any body send me the perfect answer?

5473