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

In oracle there is column command, how will you explain that?

986


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

1013


How to drop a stored function?

1091


Is postgres faster than oracle?

980


Explain what does a control file contain?

1043


What is a lookup table in oracle?

942


Hi this srilatha. I comlpeted my Oracle-hrms. can u provide me interview questions on Core hr, payroll,sshr,OLM etc..

2073


What is materialized view in Oracle?

1046


How would you begin to troubleshoot an ORA-3113 error?

2038


what is insert all statement in sql

6413


How to see free space of each tablespace?

982


Why packages are used in oracle?

1011


What to do if dba lost the system password?

1104


What is the difference between a primary key & a unique key?

1047


 How to use an oracle sequence generator in a mapping?

1029