, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear AND b1.WKMONTH = '09' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y0M9CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear AND b1.WKMONTH = '10' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y0M10CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear AND b1.WKMONTH = '11' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y0M11CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear AND b1.WKMONTH = '12' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y0M12CNT
<#end 조회조건이 1개년도일때만 >
<#if 조회조건이 3개년도일때만 >
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '01' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M1CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '02' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M2CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '03' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M3CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '04' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M4CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '05' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M5CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '06' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M6CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '07' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M7CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '08' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M8CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '09' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M9CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '10' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M10CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '11' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M11CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accstYear OR b1.WKYEAR = :accedYear THEN NULL
WHEN b1.WKMONTH = '12' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y1M12CNT
<#end 조회조건이 3개년도일때만 >
<#if 조회조건이 2~3개년도일때만 >
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '01' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M1CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '02' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M2CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '03' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M3CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '04' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M4CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '05' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M5CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '06' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M6CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '07' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M7CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '08' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M8CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '09' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M9CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '10' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M10CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '11' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M11CNT
, NVL(MAX(CASE WHEN b1.WKYEAR = :accedYear AND b1.WKMONTH = '12' THEN DECODE(b5.UNIT, 'RT', AVG_D_CNT || '%', SUM_CNT) ELSE NULL END),0) AS Y2M12CNT
<#end 조회조건이 2~3개년도일때만 >
, NVL(SUM.......합계쿼리)
, NVL(SUM.......합계쿼리2)
, NVL(SUM.......평균쿼리)
, NVL(SUM.......평균쿼리2)
FROM( SELECT XXXX,XXX,XXX
FROM TABLES....
WHERE ....
/* 대략 DATA 수는 항목이 150개, 각 항목별 집계는 일자별로하고 월별로 SUM하여 보여줍니다. */