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

How to store only time; not date and time?

1015


Can multiple columns be used in group by in oracle?

970


What is the difference between the Oracle ODBC driver and a Microsoft ODBC (Open Database Connectivity) Driver?

1094


How can I convert single byte kana characters into multi byte kana characters and vice-versa.

2388


What are the different types of record groups in oracle? Explain each of them

1019


What is ceil and floor in oracle?

1063


When system tablespace is created?

1028


Explain oracle instance.

1162


Can a parameter be passed to a cursor?

1110


What is an oracle function?

1146


Explain what are the characteristics of data files?

1077


Name the various constraints used in oracle?

1011


What is the usage of synonyms?

1133


How to check the server version in oracle?

1085


How to check the oracle tns settings?

1040