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

How to empty your oracle recycle bin?

980


What are the differences between blob and clob in oracle?

1029


Explain the use of grant option in exp command.

1004


How to retrieve values from data fields in record variables?

1033


What is open database communication (odbc) in oracle?

948


Explain self joins in oracle?

949


How to set a transaction to be read only in oracle?

1031


How to list all user accounts in oracle?

979


Hi friends can u send the oracle 9i full version download link?????????????? please reply ?

1813


How would you configure your networking files to connect to a database by the name of DSS which resides in domain icallinc.com?

1871


How to write text literals in oracle?

1019


How to create a stored program unit?

1116


How to assign a table row to a record variable?

966


What is a trigger and what are its types in oracle?

998


Can you assign multiple query result rows to a variable?

931