您的位置:首页 > 数据库

sql 中对分组的信息进行聚合。(sql server 2005)

2010-08-20 11:50 337 查看
代码with t as(
select 1 id, 'Child1' child
union
select 1 id, 'Child2'
union
select 1 id, 'Child3'
union
select 2 id, 'Child1'
union
select 2 id, 'Child2'
)

select id, stuff((select ','+child
from t a
where b.id = a.id
for xml path('')),1,1,'') children
from t b group by id
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐