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

6. Display the client name and order date for all orders using the traditional method.

2262


What is varray?

1061


How to rename an index in oracle?

1081


How different is ms access and oracle?

997


What is rowid and rownum in oracle?

969


Can select statements be used on views in oracle?

1002


In not less than 100 words what's the main difference between Rolap and Molap in ORACLE ?

2232


What are the tools for Oracle ?

1022


How to establish administrator authentication to the server?

999


Which is better Oracle or MS SQL? Why?

4856


How to run the anonymous block again?

1082


What is the usage of control file in oracle?

1046


What is the usage of save points in oracle database?

927


How oracle handles dead locks?

1036


what is difference between sql plus and sql*plus? (not sql and sql plus).

3841