SELECT A.INCIDENTPROGRESS,A.COUNT AS COUNT1, B.COUNT AS COUNT2, C.COUNT AS COUTN3, D.COUNT AS COUNT4 FROM
(SELECT INCIDENTPROGRESS, COUNT(DECODE(INCIDENTCODE,1,1,NULL))AS COUNT FROM TB_OP_INCIDENT GROUP BY INCIDENTPROGRESS) A,
(SELECT INCIDENTPROGRESS, COUNT(DECODE(INCIDENTCODE,2,1,NULL))AS COUNT FROM TB_OP_INCIDENT GROUP BY INCIDENTPROGRESS) B,
(SELECT INCIDENTPROGRESS, COUNT(DECODE(INCIDENTCODE,3,1,NULL))AS COUNT FROM TB_OP_INCIDENT GROUP BY INCIDENTPROGRESS) C,
(SELECT INCIDENTPROGRESS, COUNT(DECODE(INCIDENTCODE,4,1,NULL))AS COUNT FROM TB_OP_INCIDENT GROUP BY INCIDENTPROGRESS) D
WHERE
A.INCIDENTPROGRESS = B.INCIDENTPROGRESS AND
A.INCIDENTPROGRESS = C.INCIDENTPROGRESS AND
A.INCIDENTPROGRESS = D.INCIDENTPROGRESS
ORDER BY INCIDENTPROGRESS;
현재 이렇게 짜여져 있는 쿼리를 PIVOT을 사용해서 변경할려고 합니다.
그런데 PIVOT을 사용해보지 않아 어렵네요
선배님들의 조언 부탁드립니다.