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 / bhanu yadav

For Nth Max.

select distinct a.sal from emp a where &N= (select count
(distinct b.sal) from emp b where b.sal>=a.sal)

For Nth Min.

select distinct a.sal from emp a where &N= (select count
(distinct b.sal) from emp b where b.sal<=a.sal)

Is This Answer Correct ?    9 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to define an oracle sub procedure?

1048


what is the need of indexing topic in oracle? where do we use in a Java project? any other option other than using this to get the same result where we use indexing ?

2410


State the difference along with examples between Oracle 9i, Oracle 10g and Oracle 11i.

974


What is oracle database 10g express edition?

1069


What is user managed backup in Oracle?

1073


What are the uses of linked server and explain it in detail?

1000


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

2124


How to run queries on external tables?

987


List out the difference between commit, rollback, and savepoint?

985


In what script is snap$ created? In what script is the scott/tiger schema created?

2653


Explain oracle instance.

1102


How to convert times to characters in oracle?

976


How to start an oracle instance?

950


How to create a table index in oracle?

1081


How to use in conditions in oracle?

992