WITH t AS ( SELECT 'A' gb, 'X' cd, 11 v1, 12 v2, 13 v3 FROM dual UNION ALL SELECT 'A', 'Y', 21, 22, 23 FROM dual UNION ALL SELECT 'A', 'Z', 31, 32, 33 FROM dual UNION ALL SELECT 'B', 'X', 41, 42, 43 FROM dual UNION ALL SELECT 'B', 'Y', 51, 52, 53 FROM dual UNION ALL SELECT 'B', 'Z', 61, 62, 63 FROM dual ) -- 1. GROUP BY, MIN(DECODE()) SELECT gb , 'X' x0 -- 이 부분이 꼭 필요한지? 없어도 될 듯. , MIN(DECODE(cd, 'X', v1)) x1 , MIN(DECODE(cd, 'X', v2)) x2 , MIN(DECODE(cd, 'X', v3)) x3 , 'Y' y0 , MIN(DECODE(cd, 'Y', v1)) y1 , MIN(DECODE(cd, 'Y', v2)) y2 , MIN(DECODE(cd, 'Y', v3)) y3 , 'Z' z0 , MIN(DECODE(cd, 'Z', v1)) z1 , MIN(DECODE(cd, 'Z', v2)) z2 , MIN(DECODE(cd, 'Z', v3)) z3 FROM t GROUP BY gb ORDER BY gb ; -- 2. PIVOT SELECT * FROM t PIVOT (MIN(v1) "1", MIN(v2) "2", MIN(v3) "3" FOR cd IN ('X' x, 'Y' y, 'Z' z)) ;