select col1, regexp_replace( listagg(col2, ',') within group (order by col2) ,'([^,]+)(,\1)+', '\1') where rn = 1 group by col1;