{column:width=50%}
select yyyymmdd, sum(inp_amt), sum(out_amt)
from (select MANAGE_NUM, substr(yyyymm,1,6) yyyymmdd
from ACCOUNT a, MONTH_DUAL d
where a.DEPT_COD = 'AA'
and d.yyyymm between '20060301' and '20060430') x,
(select MANAGE_NUM, substr(INPUT_DATE,1,6) inp_date, sum(AMT) inp_amt
from INPUT
where INPUT_DATE between '20060301' and '20060430'
group by MANAGE_NUM, substr(INPUT_DATE,1,6)) b,
(select MANAGE_NUM, substr(OUTPUT_DATE,1,6) out_date, sum(AMT) out_amt
from OUTPUT
where OUTPUT_DATE between '20060301' and '20060430'
group by MANAGE_NUM, substr(OUTPUT_DATE,1,6)) c
where b.MANAGE_NUM(+) = x.MANAGE_NUM
and b.inp_date(+) = x.yyyymmdd
and c.MANAGE_NUM(+) = x.MANAGE_NUM
and c.out_date(+) = x.yyyymmdd
group by yyyymmdd;
{column}
{column:width=50%}
Execution Plan
----------------------------------------------------------
Plan hash value: 3193331423
---------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------
| 0 |SELECTSTATEMENT | | 36 | 2556 | 18 (23) | 00:00:01 |
| 1 | HASHGROUPBY | | 36 | 2556 | 18 (23) | 00:00:01 |
|* 2 | HASH JOIN OUTER | | 36 | 2556 | 17 (18) | 00:00:01 |
|* 3 | HASH JOIN OUTER | | 36 | 1548 | 13 (16) | 00:00:01 |
| 4 | VIEW | | 36 | 540 | 8 (0) | 00:00:01 |
| 5 | MERGE JOIN CARTESIAN| | 36 | 720 | 8 (0) | 00:00:01 |
|* 6 | TABLE ACCESS FULL | ACCOUNT | 3 | 42 | 3 (0) | 00:00:01 |
| 7 | BUFFER SORT | | 12 | 72 | 5 (0) | 00:00:01 |
|* 8 | TABLE ACCESS FULL | MONTH_DUAL | 12 | 72 | 2 (0) | 00:00:01 |
| 9 | VIEW | | 9 | 252 | 4 (25) | 00:00:01 |
| 10 | HASHGROUPBY | | 9 | 234 | 4 (25) | 00:00:01 |
|*11 | TABLE ACCESS FULL | INPUT | 9 | 234 | 3 (0) | 00:00:01 |
| 12 | VIEW | | 9 | 252 | 4 (25) | 00:00:01 |
| 13 | HASHGROUPBY | | 9 | 234 | 4 (25) | 00:00:01 |
|*14 | TABLE ACCESS FULL | OUTPUT | 9 | 234 | 3 (0) | 00:00:01 |
---------------------------------------------------------------------------------------
Predicate Information (identifiedbyoperation id):
---------------------------------------------------------------------------------------
2 - access("C"."MANAGE_NUM"(+)="X"."MANAGE_NUM"AND"C"."OUT_DATE"(+)="X"."YYYYMMDD")
3 - access("B"."MANAGE_NUM"(+)="X"."MANAGE_NUM"AND"B"."INP_DATE"(+)="X"."YYYYMMDD")
6 - filter("A"."DEPT_COD"='AA') 8 - filter("D"."YYYYMM">='20060301' AND"D"."YYYYMM"<='20060430')
11 - filter("INPUT_DATE">='20060301' AND"INPUT_DATE"<='20060430')
14 - filter("OUTPUT_DATE">='20060301' AND"OUTPUT_DATE"<='20060430')
{column}