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 raw datatype?

1132


What is connection pool in oracle?

981


What is a sub query? Describe its types?

1011


What does sharding mean?

990


How to pass parameters to procedures in oracle?

1035


What is the difference between sharding and replication?

1031


How to display employee records who gets more salary than the average salary in the department?

1059


What is the difference between Delete, Truncate and Drop in Oracle?

1122


Is oracle an operator?

921


How i can handle exception in large code like 1000 line without distrubing the code or without exception handler sction?

3193


6. Display the client name and order date for all orders using the traditional method.

2299


what is partitioning? Types of partitioning. explain? what is the new kind of partitioning type introduced in 9i?

2261


What is the sql query to concatenate column values from multiple rows in oracle?

1044


How a database is related to tablespaces?

1024


What is SQL access advisor in Oracle?

1182