Query to get max and second max in oracle in one query ?
Answer Posted / sumit wadhwa
select distinct(a.colname) from table a where &n=(select
count(distinct(b.colname)) from table b where
a.colname<=b.colname);
from this query u can find out Nth MAX in a one query
eg
select distinct(a.sal) from emp a where &n=(select count
(distinct(b.sal)) from emp b where a.sal<=b.sal);
| Is This Answer Correct ? | 55 Yes | 16 No |
Post New Answer View All Answers
How many categories of data types?
What is a cursor and what are the steps need to be taken?
Assuming that you are an End User How to find that in the payment Batch some of the Invoice was Missing To pay How to find That??
How to load data through external tables?
query optmization techniques and quwry analyser+projects+ppts
Can we store pictures in the database and if so, how it can be done?
What is a static data dictionary in oracle?
defination of bitmap index
What do you mean by a deadlock?
From the following identify the non schema object: packages, triggers, public synonyms, tables and indexes.
What is the max number of columns in an oracle table?
How to enter a new row into a table interactively?
What are the tools for Oracle ?
What are the various types of snapshots ?
What privilege is needed for a user to create tables in oracle?