select
--1월
NVL((SELECT NVL(DAR00,0) AS MON1SALE FROM TB_FIAR_010
WHERE TB_FIAR_010.MANDT = FIAR010.MANDT AND TB_FIAR_010.BUKRS = FIAR010.BUKRS
AND TB_FIAR_010.KUNNR = FIAR010.KUNNR AND TB_FIAR_010.KKBER = FIAR010.KKBER
AND SUBSTR(TB_FIAR_010.BDATE,1,4) = '2013'
AND SUBSTR(TB_FIAR_010.BDATE,6,2) = '01'
AND SUBSTR(TB_FIAR_010.BDATE,9,2) = (SELECT MAX(SUBSTR(TB_FIAR_010.BDATE,9,2))
FROM TB_FIAR_010
WHERE TB_FIAR_010.MANDT = FIAR010.MANDT AND TB_FIAR_010.BUKRS = FIAR010.BUKRS
AND TB_FIAR_010.KUNNR = FIAR010.KUNNR AND TB_FIAR_010.KKBER = FIAR010.KKBER
AND SUBSTR(TB_FIAR_010.BDATE,1,4) = SUBSTR(FIAR010.BDATE,1,4)
AND SUBSTR(TB_FIAR_010.BDATE,6,2) = '01'
)
AND ROWNUM = 1
),0) AS MON1SALE,
NVL((SELECT NVL(DCASH,0) + NVL(DGUME,0) + NVL(DPANM,0) + NVL(DTASU,0) + NVL(DJASU,0) +
NVL(DETAS,0) + NVL(DEJAS,0) + NVL(DECHE,0) + NVL(DWDAM,0) AS MON1INCOME FROM TB_FIAR_010
WHERE TB_FIAR_010.MANDT = FIAR010.MANDT AND TB_FIAR_010.BUKRS = FIAR010.BUKRS
AND TB_FIAR_010.KUNNR = FIAR010.KUNNR AND TB_FIAR_010.KKBER = FIAR010.KKBER
AND SUBSTR(TB_FIAR_010.BDATE,1,4) = '2013'
AND SUBSTR(TB_FIAR_010.BDATE,6,2) = '01'
AND SUBSTR(TB_FIAR_010.BDATE,9,2) = (SELECT MAX(SUBSTR(TB_FIAR_010.BDATE,9,2))
FROM TB_FIAR_010
WHERE TB_FIAR_010.MANDT = FIAR010.MANDT AND TB_FIAR_010.BUKRS = FIAR010.BUKRS
AND TB_FIAR_010.KUNNR = FIAR010.KUNNR AND TB_FIAR_010.KKBER = FIAR010.KKBER
AND SUBSTR(TB_FIAR_010.BDATE,1,4) = SUBSTR(FIAR010.BDATE,1,4)
AND SUBSTR(TB_FIAR_010.BDATE,6,2) = '01'
)
AND ROWNUM = 1
),0) AS MON1INCOME
select문 중에서 1월것만 잘라서 가져왔는데요 BDATE의 1월~12월 데이터를 가져오는 쿼리문입니다
결과는 MON1SALE MON1INCOME ...............
253000 12000 .................
이렇게 나오는데 이거를
MONSALE MONINCOME
25300 12000
. .
. .
. .
. .
이렇게 세로로 출력해서 보고 싶은데 어떻게 해야할까요?ㅠㅠ
Comment 1
-
Hisory
2014.03.19 11:15
내용을 자세히 살펴보지는 않았지만... pivot or unpivot 를 사용하시면 되지않을까 싶습니다