这个场景很常见,在网上查了一下,人家说用xpath 方法,亲测有效。
select stuff( (select ‘,‘+cast(u.UserName_Chn as varchar(max)) from BO_ManagementPeo b inner join V_P_UserInfo u on u.UserGUID = b.UserGUID where a.ObjectGUID=b.ObjectGUID for xml path(‘‘)) ,1,1,‘‘) as JoinUsers, ObjectGUID from BO_ManagementPeo a group by ObjectGUID
时间: 2024-11-20 16:56:05