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

select * from emp a where 2 > (select count(distinct sal)
from emp b where b.sal > a.sal)
or else use Top Window functions (or) Analatical functions
select * from
(
select empno,ename,sal,rank() over (order by sal desc)
test from emp
)
where test <= 2

Is This Answer Correct ?    12 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to check database size in Oracle?

1193


What is define in oracle?

1061


Can multiple cursors being opened at the same time?

1062


How do we get field details of a table?

981


How to recover a dropped table in oracle?

1048


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

2309


How to loop through a cursor variable?

1089


how to handle exceptions in post production

1429


What is the difference between hot backup and cold backup in oracle?

1014


What is materialized view in Oracle?

1075


Explain the use of compress option in exp command.

1021


Which is faster join or subquery in oracle?

996


Why does for update in oracle 8 cause an ora-01002 error?

1003


How to check your oracle database 10g xe installation?

989


How to pass a parameter to a cursor in oracle?

1186