select col1,
regexp_replace(listagg(col2 , ',') within group (order by col2),'([^,]+)(,\1)*(,|$)', '\1\3') ) from tableX where rn = 1 group by col1;
Tags:
Oracle
select col1,
regexp_replace(listagg(col2 , ',') within group (order by col2),'([^,]+)(,\1)*(,|$)', '\1\3') ) from tableX where rn = 1 group by col1;