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 / kevin sharpless

-- This query wiil return any number of the n items by
using the max/decode statements

select max(decode(rnum,1,salary,null)) max1
,max(decode(rnum,2,salary,null)) max2
from (
select 1 grp_col
,salary
,row_number() over (order by salary asc) rnum
from (
select distinct salary
from emp
)
)
group by grp_col

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Assuming that you are an End User How to find that in the payment Batch some of the Invoice was  Missing To pay How to find That??

1789


How to create a table in a specific tablespace?

1028


Explain about the analyze command in oracle?

1112


How to open and close an explicit cursor in oracle?

1097


What is the difference between count (*), count (expression), count (distinct expression)?

1046


What is an Oracle Instance?

1163


How do I know if oracle client is installed on windows?

1093


Can we commit inside a function in oracle?

1013


What's dateware house and what's clustor with practicle example

2234


How to get a create statement for an existing table?

1014


Difference between hot backup vs. Cold backup?

1039


What are transaction isolation levels supported by oracle?

1116


how to clone 9i Database on to 10g Database.

2385


Explain the types of exception?

1194


Please explain joins in oracle?

1106