SELECT
AC AS TABLE_NAME,
SUM(DECODE(MM,'01',CNT)) AS M1,
SUM(DECODE(MM,'02',CNT)) AS M2,
SUM(DECODE(MM,'03',CNT)) AS M3,
SUM(DECODE(MM,'04',CNT)) AS M4,
SUM(DECODE(MM,'05',CNT)) AS M5,
SUM(DECODE(MM,'06',CNT)) AS M6,
SUM(DECODE(MM,'07',CNT)) AS M7,
SUM(DECODE(MM,'08',CNT)) AS M8,
SUM(DECODE(MM,'09',CNT)) AS M9,
SUM(DECODE(MM,'10',CNT)) AS M10,
SUM(DECODE(MM,'11',CNT)) AS M11,
SUM(DECODE(MM,'12',CNT)) AS M12
FROM
(SELECT TABLE_NAME AC, SUBSTR(A.TDM_RELEASE_DATE,6,2) MM, COUNT(B.EVENT_TYPE) CNT
FROM
( SELECT OBJECT_ID, TO_CHAR(TDM_RELEASE_DATE,'yyyy-MM-dd') TDM_RELEASE_DATE FROM TN_MP_ENGINEERING_CHANGE
UNION
SELECT OBJECT_ID, TO_CHAR(TDM_RELEASE_DATE,'yyyy-MM-dd') TDM_RELEASE_DATE FROM TN_MP_FIRST_RELEASE
UNION
SELECT OBJECT_ID, TO_CHAR(TDM_RELEASE_DATE,'yyyy-MM-dd') TDM_RELEASE_DATE FROM TN_PROTO_RELEASE
UNION
SELECT OBJECT_ID, TO_CHAR(TDM_RELEASE_DATE,'yyyy-MM-dd') TDM_RELEASE_DATE FROM TN_ROUTING_CHANGE
UNION
SELECT OBJECT_ID, TO_CHAR(TDM_RELEASE_DATE,'yyyy-MM-dd') TDM_RELEASE_DATE FROM TN_ROUTING_EC
UNION
SELECT OBJECT_ID, TO_CHAR(TDM_RELEASE_DATE,'yyyy-MM-dd') TDM_RELEASE_DATE FROM TN_ROUTING_PILOT_RELEASE
UNION
SELECT OBJECT_ID, TO_CHAR(TDM_RELEASE_DATE,'yyyy-MM-dd') TDM_RELEASE_DATE FROM TN_PACKING_CHANGE
UNION
SELECT OBJECT_ID, TO_CHAR(TDM_RELEASE_DATE,'yyyy-MM-dd') TDM_RELEASE_DATE FROM TN_PACKING_EC
UNION
SELECT OBJECT_ID, TO_CHAR(TDM_RELEASE_DATE,'yyyy-MM-dd') TDM_RELEASE_DATE FROM TN_PACKING_PILOT_RELEASE
) A,
(SELECT EVENT_TYPE,EO_CLASS_ID,EO_OBJECT_ID,TABLE_NAME
FROM EO_EVENT T1,TDM_CLASS T2
WHERE T1.EO_CLASS_ID=T2.CLASS_ID
) B
WHERE B.EO_OBJECT_ID = A.OBJECT_ID
AND A.TDM_RELEASE_DATE like '2008%'
GROUP BY TABLE_NAME, SUBSTR(A.TDM_RELEASE_DATE,6,2)
)
GROUP BY AC
'SQL > Query' 카테고리의 다른 글
[본문스크랩] 오라클 모니터링 하기 위한 쿼리 2 (0) | 2014.06.11 |
---|---|
[링크스크랩] 오라클 select 를 이용한 내용 확인 (0) | 2014.06.11 |
SELECT한 내용을 INSERT하기 (0) | 2014.06.11 |
테이블 컬럼상세 조회하기 (0) | 2014.06.11 |
지정 연,월에 해당하는 날짜수만큼 row를 생성하기 (0) | 2014.06.11 |
행열 바꾸기 1,2,3등으로 구분되어진 항목을 열로 변환하기 (0) | 2014.06.11 |
파일을 읽어서 매핑값을 BULK INSERT (0) | 2014.06.11 |
비슷한 테이블 매크로 생성 (0) | 2014.06.11 |