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 / mats önnerby

--- Three level query
--- 1. Find and order all distinct salaries
--- 2. Pick the two top salaries
--- 3. Get all information about employees with that salary

select *
from emp
where sal in (
select sal from (
select distinct sal
from emp
order by sal desc)
where rownum <= 2);
---
--- Simple and straight forward but will return
--- several employees in case they have the same salary
---

Is This Answer Correct ?    12 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an oracle data file?

1053


What is logical backup in oracle?

976


How to write text literals in oracle?

1031


What is background process in Oracle?

1061


How to end the current transaction in oracle?

974


What is truncate oracle?

924


How to pass a parameter to a cursor in oracle?

1122


I have a database backup file in .db (ext) form how to conver it into .dmp (ext.) for oracle database

2088


What is hot backup and logical backup?

1010


How do I use os authentication with weblogic jdriver for oracle and connection pools?

1009


How can Oracle users be audited?

1067


How to create a single index for multiple columns?

989


What are oracle functions?

991


How to define and use table alias names in oracle?

892


what is port in oracle? how is it related to database application.

1903