with
t_table as
(
select 1 as seq, '2006' as year, 1 as quarter, 1 as gubun, '김' as name from dual union all
select 2 as seq, '2006' as year, 1 as quarter, 2 as gubun, '이' as name from dual union all
select 3 as seq, '2006' as year, 1 as quarter, 3 as gubun, '박' as name from dual union all
select 4 as seq, '2006' as year, 1 as quarter, 3 as gubun, '성' as name from dual union all
select 5 as seq, '2006' as year, 1 as quarter, 3 as gubun, '강' as name from dual union all
select 6 as seq, '2006' as year, 1 as quarter, 3 as gubun, '최' as name from dual
)
select gubun
, substr (max (sys_connect_by_path (name, ',')), 2)
from
(
select gubun
, name
, row_number() over (partition by gubun order by seq) as rnum
from t_table
)
start with rnum = 1
connect by prior rnum = rnum - 1
and prior gubun = gubun
group by gubun