Query to get max and second max in oracle in one query ?
Answer Posted / kevin sharpless
-- This query wiil return any number of the n items by
using the max/decode statements
select max(decode(rnum,1,salary,null)) max1
,max(decode(rnum,2,salary,null)) max2
from (
select 1 grp_col
,salary
,row_number() over (order by salary asc) rnum
from (
select distinct salary
from emp
)
)
group by grp_col
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
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 create a table in a specific tablespace?
Explain about the analyze command in oracle?
How to open and close an explicit cursor in oracle?
What is the difference between count (*), count (expression), count (distinct expression)?
What is an Oracle Instance?
How do I know if oracle client is installed on windows?
Can we commit inside a function in oracle?
What's dateware house and what's clustor with practicle example
How to get a create statement for an existing table?
Difference between hot backup vs. Cold backup?
What are transaction isolation levels supported by oracle?
how to clone 9i Database on to 10g Database.
Explain the types of exception?
Please explain joins in oracle?