-- 다이나믹 쿼리로 짜셔야할듯합니다. WITH T1 (id, code, result) AS ( SELECT 'aaa' , 'X' , '성공' FROM DUAL UNION ALL SELECT 'aaa' , 'Y' , '실패' FROM DUAL UNION ALL SELECT 'bbb' , 'X' , '성공' FROM DUAL UNION ALL SELECT 'bbb' , 'Y' , '실패' FROM DUAL UNION ALL SELECT 'ccc' , 'X' , '성공' FROM DUAL ) , T2 (id, name )AS ( SELECT 'aaa' , '홍길동' FROM DUAL UNION ALL SELECT 'bbb' , '성춘향' FROM DUAL UNION ALL SELECT 'ccc' , '고길동' FROM DUAL ) SELECT T1.id ,MAX(T2.name) -- .... 요기부턴 다이나믹 쿼리로 ,MAX(DECODE(CODE,'X',result)) x ,MAX(DECODE(CODE,'Y',result)) Y -- .... -- .... -- .... FROM T1 , T2 WHERE T1.ID = T2.ID GROUP BY T1.ID