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

SELECT Sal
FROM (Select Sal from Emp_Salary order by Sal desc)
WHERE rownum < =2;


Above query will fetch two rows. First row is the max salary
and second row second max.

IF we only need to find second max, then

SELECT Min(Sal)
FROM (Select Sal from Emp_Salary order by Sal desc)
WHERE rownum < =2;

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I just want to maintain data like an employee can belongs to 3 or more departments . We can resolve this by using composite key but it avoids normalization rules. So Can anyone tell me how can I maintain data.

2246


 What are the oracle DML commands possible through an update strategy?

1104


What is oracle latest version?

1152


How to use "in out" parameter properly?

1103


What are the system predefined user roles?

1099


What is program global area (pga) in oracle?

1091


In which language oracle has been developed?

1134


How to connect to the server with user account: sys?

1061


Who developed oracle & when?

1058


How do I start tns listener?

1096


Calculate difference between 2 date / times in oracle sql?

1098


What is oracle data type?

1008


How do I find the database name in oracle?

1089


How to check your oracle database 10g xe installation?

1049


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

1139