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

Which is better Oracle or MS SQL? Why?

5033


How view is different from a table?

1082


What is the fastest query method to fetch data from the table?

1415


What is a user role in oracle?

1184


Hi friends can u send the oracle 9i full version download link?????????????? please reply ?

1922


What's dateware house and what's clustor with practicle example

2234


21. Using a set operator, display the client number of all clients who have ever placed an order and whose whose name does not contain the string Sm.

2166


What is connection pool in oracle?

1037


How to divide query output into groups in oracle?

1032


How to define and use table alias names in oracle?

989


Can we insert data in view oracle?

1119


How to specify default values in insert statement using oracle?

1153


How to store pictures on to the database?

1033


Whats the benefit of dbms_stats over analyze?

2065


What is the difference between "as" and "is" in an oracle stored procedure?

1046