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

for max

select a.sal
from emp a
where 1=(select distinct(count(b.sal))
from emp b
where a.sal<=b.sal);

for second max

select a.sal
from emp a
where 2=(select distinct(count(b.sal))
from emp b
where a.sal<=b.sal)

Is This Answer Correct ?    33 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an oracle transaction?

1146


What is sharded cluster?

1015


what is Single Byte Overhead...?

2555


What is Undo Management Advisor in Oracle?

1098


what is the difference between restoring and recovering?

1011


What are the different types of modules in oracle forms?

1001


How to create additional tablespaces for an new database?

1027


Is oracle a relational database?

916


How to use windows user to connect to the server?

989


Database crashes. Corruption is found scattered among the file system neither of your doing nor of Oracles. What database recovery options are available? Database is in archive log mode.

2007


What happens to the current transaction if a ddl statement is executed?

1013


What are the common oracle dba tasks?

1148


How to sort output in descending order in oracle?

1045


How to fetch the row which has the max value for a column?

1001


Explain the use of grant option in imp command.

1030