Di Oracle, Anda dapat menggunakan listagg()
, tetapi tidak memiliki distinct
pilihan. Jadi, gunakan subquery dan dua tingkat agregasi:
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;