WITH T AS ( SELECT 100 id, 'F' AS res FROM DUAL UNION ALL SELECT 100, 'F' FROM DUAL UNION ALL SELECT 200, 'S' FROM DUAL UNION ALL SELECT 200, 'S' FROM DUAL UNION ALL SELECT 300, 'S' FROM DUAL UNION ALL SELECT 300, 'F' FROM DUAL ) SELECT id, res, CASE WHEN INSTR(res, 'FS') > 0 OR INSTR(res, 'SF') > 0 THEN '일부실패' WHEN INSTR(res, 'F') > 0 THEN '실패' ELSE '성공' END FROM ( SELECT id, LISTAGG(res) WITHIN GROUP(ORDER BY id) AS res FROM T GROUP BY id )