1 select ID,max(substr((sys_connect_by_path(name,',')),2)) cola
2 from (
3 select id,name,
4 rownum rnum,
5 row_number() over(partition by id order by id) rn1
6 from test_pppp
7 )
8 start with rn1=1
9 connect by rnum-1=prior rnum
10* group by id
SQL> select * from test_pppp;
ID NAME
---------- ----------
A AAA
A BBB
A CCC
B AAA
B CCC
ID COLA
---------- ------------------------------------------
A AAA,BBB,CCC
B AAA,CCC