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 are the extensions used by oracle reports?
What is the usage of merge statement?
how to handle exceptions in post production
What are the different types of trigger and explain its various uses and functions?
What is the difference between sharding and replication?
What are the different types of synonyms?
How different is ms access and oracle?
Is oracle a programming language?
Does oracle partitioning improve performance?
What is a partition in oracle?
How do we get field detail of a table?
Explain the use of rows option in imp command.
What is the disadvantage of User defind function?
What are a query and state the different types of queries and their uses?
how to code performance tuning of oracle PL/SQL? can any body send me the perfect answer?