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
What is Virtual Private Database in Oracle?
State any two functions of oracle?
Typically, where is the conventional directory structure chosen for Oracle binaries to reside?
How to write date and time interval literals in oracle?
Why is oracle used?
How to write date and time literals in oracle?
Differentiate between translate and replace?
What is an Oracle Instance?
Is oracle a relational database?
What is a cursor variable?
You have found corruption in a tablespace that contains static tables that are part of a database that is in NOARCHIVE log mode. How would you restore the tablespace without losing new data in the other tablespaces?
Is there any function in oracle similar like group_concat of mysql?
What is the parameter mode that can be passed to a procedure?
What is bulk copy or bcp in oracle?
What is a database schema in oracle?