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

What happens if the update subquery returns multiple rows?

1109


What are named parameters?

1085


How to speed up webrick?

1069


how to join query for one source type is oracle another source type is sql server ?

2420


In AP we done Customizations for Late Payments Charges. For Reporting Purpose What are the Documents Prepared for Customer Understanding??

1649


How to add a new column to an existing table in oracle?

1131


How to insert a record into a table?

1064


what is a Nested Loop join?

2103


State the difference between a primary key and foreign key?

930


How many types of database triggers exist?

1125


What do you mean by merge in oracle?

991


Which environment variables are absolutely critical in order to run the OUI?

2114


How to create a new view in oracle?

1069


How would you change old and new values in an insert, delete and update triggers?

1011


Difference between inner join vs where ?

1029