oracle 的分组字符串合并
http://www.itpub.net/thread-1702620-1-1.html
试试这个
select id, ltrim(sys_connect_by_path(name, ','), ',') name
from (select id,
name,
row_number() over(partition by id order by name) rn,
count(*) over(partition by id) cnt
from table) t
where rn = cnt
start with rn = 1
connect by prior id = id
and prior rn = rn - 1
order by id;
把table换成你的表名,id和name为你表里的字段
用函数wmsys.wm_concat
select id, wmsys.wm_concat(name) as names
from table
group by id
order by id
用函数wmsys.wm_concat
select id, wmsys.wm_concat(name) as names
from table
group by id
order by id