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 to connect ms access to oracle servers?
What is an anonymous block?
types of indexes and the rationale behind choosing a particular index for a situation.
What is rich query?
How to define an external table with a text file?
Explain how are indexes update?
How to define an anonymous procedure with variables?
How to download oracle database 10g xe?
How to best split csv strings in oracle 9i?
Explain the use of record option in exp command.
What is index-organized table in Oracle?
How to create a table index in oracle?
How to run queries on external tables?
Give the different types of rollback segments.
What is a subquery in oracle?