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
In oracle there is column command, how will you explain that?
What is a trigger and what are its types in oracle?
How to drop a stored function?
Is postgres faster than oracle?
Explain what does a control file contain?
What is a lookup table in oracle?
Hi this srilatha. I comlpeted my Oracle-hrms. can u provide me interview questions on Core hr, payroll,sshr,OLM etc..
What is materialized view in Oracle?
How would you begin to troubleshoot an ORA-3113 error?
what is insert all statement in sql
How to see free space of each tablespace?
Why packages are used in oracle?
What to do if dba lost the system password?
What is the difference between a primary key & a unique key?
 How to use an oracle sequence generator in a mapping?