首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

[SQLServer]将多条记要的一个字段进行连接

2012-08-21 
[SQLServer]将多条记录的一个字段进行连接for xml path(root)select tt.organization_id, left(list,len

[SQLServer]将多条记录的一个字段进行连接
for xml path('root')

select tt.organization_id, left(list,len(list)-1) from (   select t.organization_id,(    select cast(party_id as varchar) + ','       from hrs_employee for xml path('')   ) as list   from hrs_employee t group by t.organization_id) tt


1    0,0,1,1,8000001000002,8000001000003
99   0,0,1,1,8000001000002,8000001000003




热点排行