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 / ajit

select max(sal),1 no
from emp
union
select sal,rn from (select sal,rownum rn from emp)
where rn = 2
order by 1 desc;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why cursor variables are easier to use than cursors?

1139


15. Display the item_cost and then truncate it to the nearest hundred, ten, unit, tenth and hundredth.

2356


In the oracle version 9.3.0.5.0, what does each number shows?

1344


How to call a stored function with parameters?

1095


What is a database table in oracle?

1070


Is there a combination of "like" and "in" in sql?

1114


How to create a stored function in oracle?

1157


What is format trigger?

2120


WHEN CURSOR MOVES FROM ONE FORM TO ANOTHER FORM, HOW MANY TRIGGER WILL BE FIRED AND WHAT ARE THEIR SEQUENCE?

2361


How to lock and unlock a user account in oracle?

1161


What is partitioned table in Oracle?

1268


1) Does oracle have any table which contain all the exceptions and it's code internally?

1804


Explain the use of control file?

1177


How to check database size in Oracle?

1256


How to use subqueries with the in operator using oracle?

1138