with t as
(select 'a' name, '足球' hobby
from dual
union all
select 'a' name, '篮球' hobby
from dual
union all
select 'a' name, '乒乓' hobby
from dual
union all
select 'b' name, '游泳' hobby
from dual
union all
select 'b' name, '足球' hobby
from dual
union all
select 'c' name, '篮球' hobby from dual)
select t.name ------解决方案-------------------- ' ------解决方案-------------------- ' ------解决方案-------------------- listagg(hobby, ',') within group(order by t.name)
from t
group by t.name;
------解决方案-------------------- 把上面的within group(order by t.name)
改成
within group(order by rownum)
就ok了。 ------解决方案-------------------- SQL> select id ------解决方案-------------------- ' ------解决方案-------------------- ' ------解决方案-------------------- wm_concat(nn) from test1 group by id;
ID ------解决方案-------------------- ' ------解决方案-------------------- ' ------解决方案-------------------- WM_CONCAT(NN)
----------------------------
a ------解决方案-------------------- 足球,篮球,乒乓
b