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 call a stored function in oracle?
How do I escape a reserved word in oracle?
how to convert .db (extention) database file into .dmp (extention ) for oracle database ?
Explain how are indexes update?
Explain oracle’s server parameter file.
What is data block in Oracle?
What is the difference between formal parameters and actual parameters?
Where are the settings stored for each instance in oracle?
How to connect to the server with user account: sys?
Why does Oracle not permit the use of PCTUSED with indexes?
Explain the use of analyse option in exp command.
What is the difference between 10g OEM and 11g OEM?
State the difference along with examples between Oracle 9i, Oracle 10g and Oracle 11i.
What is the difference between the Oracle ODBC driver and a Microsoft ODBC (Open Database Connectivity) Driver?
you are a universe designer and report developer in BO, what type of information you gather from client?Briefly explain plz