에러를 확인할때는
서브쿼리를 빼 가져와서 실행을 시켜서 에러부분을 찾는 방법이 빠르거든요
full outer join을 하는 이유가 뭔지요?
그냥 JOIN을 해도 되는거 아닌가요?(빨간부분처럼)
SELECT T.*
FROM(
SELECT A.PLANT,A.DIVISION,A.INCH,A.TYPE,
DECODE(A.YYYYMM,'200512',SUM(BQTY),0) BQTY12,DECODE(A.YYYYMM,'200512',SUM(BPRICE),0) BPRICE12,
DECODE(A.YYYYMM,'200601',SUM(BQTY),0) BQTY01,DECODE(A.YYYYMM,'200601',SUM(BPRICE),0) BPRICE01
FROM
(
SELECT '200612' YYYYMM,PLANT,DIVISION,INCH,TYPE,
SUM(SQTY11) BQTY, SUM(SPRICE11) BPRICE
FROM BSPLNMCR01
WHERE YYYY = '2005'
AND PLN_TYPE = 'BP'
AND PLN_VER=FN_GET_BPVERSION('2005','CRT')
AND PLN_SEQ = 'S01'
GROUP BY PLANT,DIVISION,INCH,TYPE
UNION ALL
SELECT '200601' YYYYMM,PLANT,DIVISION,INCH,TYPE,
SUM(SQTY00) BQTY, SUM(SPRICE00) BPRICE
FROM BSPLNMCR01
WHERE YYYY = '2006'
AND PLN_TYPE = 'BP'
AND PLN_VER=FN_GET_BPVERSION('2006','CRT')
AND PLN_SEQ = 'S01'
GROUP BY PLANT,DIVISION,INCH,TYPE
) A
GROUP BY A.YYYYMM,A.PLANT,A.DIVISION,A.INCH,A.TYPE
)T, BSRPNMCR01 S
WHERE S.PLANT = T.PLANT
AND S.DIVISION = T.DIVISION
AND S.INCH = T.INCH
AND S.TYPE = T.TYPE