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

select * from emp a where 2 > (select count(distinct sal)
from emp b where b.sal > a.sal)
or else use Top Window functions (or) Analatical functions
select * from
(
select empno,ename,sal,rank() over (order by sal desc)
test from emp
)
where test <= 2

Is This Answer Correct ?    12 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the use of rows option in exp command.

1042


can u send the sql dumps to sivakumarr1987@gmail.com plz help me

3006


How to add a new column to an existing table in oracle?

1096


Difference between the “verify” and “feedback” command?

1320


What is instant client oracle?

982


How to connect asp pages to oracle servers?

1021


What are the system predefined user roles?

991


Why should I use oracle database?

959


Explain oracle’s server parameter file.

957


What is the use of oracle?

996


How to pass parameters to procedures in oracle?

1007


How to bring a tablespace offline?

1010


How to view existing locks on the database?

1005


What is an oracle and why it is used?

1091


What is tns name?

934