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 is the difference between post-database commit and post-form commit?

1186


What is a cognitive schema?

958


Explain oracle left join with an example?

1005


What is the fastest query method to fetch data from the table?

1355


Which is better Oracle or MS SQL? Why?

6381


What is the purpose of save points in oracle database?

1104


How to use null as conditions in oracle?

1076


How to assign values to data fields in record variables?

1029


How to check the server version in oracle?

1092


Hi friends can u send the oracle 9i full version download link?????????????? please reply ?

1861


What is PL/SQL ?

2050


I have a parent program and a child program. I want to write a statement in Exception Block of the parent program so that when the statement in the exception block is executed, the control goes to the next statement in the parent block bypassing the child block.How do i do that?

2457


What is an oracle transaction?

1127


You have 4 instances running on the same UNIX box. How can you determine which shared memory and semaphores are associated with which instance?

2001


How can we delete duplicate rows in a table?

971