I Oracle kan du bruge listagg()
, men den har ingen distinct
mulighed. Så brug en underforespørgsel og to aggregeringsniveauer:
select listagg(id, ',') within group (order by id) as id, name, sum(cnt)
from (select id, name, count(*) as cnt
from t
group by id, name
) x
group by name;