테스트 데이터...
WITH
t AS
(
SELECT 'a' AS item, 1 AS col, 'ㅁ' AS val FROM dual UNION ALL
SELECT 'a' AS item, 3 AS col, 'ㅁ' AS val FROM dual UNION ALL
SELECT 'a' AS item, 3 AS col, 'ㅁ' AS val FROM dual UNION ALL
SELECT 'b' AS item, 2 AS col, 'ㅇ' AS val FROM dual UNION ALL
SELECT 'b' AS item, 4 AS col, 'ㅇ' AS val FROM dual UNION ALL
SELECT 'b' AS item, 4 AS col, 'ㅇ' AS val FROM dual
)
쿼리...
SELECT
item AS 항목
, MIN(DECODE(col, 1, val)) AS "1"
, MIN(DECODE(col, 2, val)) AS "2"
, MIN(DECODE(col, 3, val)) AS "3"
, MIN(DECODE(col, 4, val)) AS "4"
, MIN(DECODE(col, 5, val)) AS "5"
, MIN(DECODE(col, 6, val)) AS "6"
FROM(
SELECT
t.*
, ROW_NUMBER() OVER(PARTITION BY item, col ORDER BY ROWNUM) AS rn
FROM t
)
GROUP BY item, rn
ORDER BY item, rn
건승하시길...수고하세요~~