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 many categories of data types?

943


What is a cursor and what are the steps need to be taken?

1133


Assuming that you are an End User How to find that in the payment Batch some of the Invoice was  Missing To pay How to find That??

1677


How to load data through external tables?

1079


query optmization techniques and quwry analyser+projects+ppts

2378


Can we store pictures in the database and if so, how it can be done?

990


What is a static data dictionary in oracle?

1039


defination of bitmap index

2056


What do you mean by a deadlock?

1018


From the following identify the non schema object: packages, triggers, public synonyms, tables and indexes.

1021


What is the max number of columns in an oracle table?

943


How to enter a new row into a table interactively?

969


What are the tools for Oracle ?

1013


What are the various types of snapshots ?

984


What privilege is needed for a user to create tables in oracle?

910