一个列转为行的问题
deptid bblistid
1 zc01
1 zc02
1 zc03
2 xx01
2 xx02
2 xx03
要求结果
deptid bblistid
1 zc01,zc02,zc03
2 xx01,xx02,xx03
[解决办法]
select deptid,
bblistid=stuff((select ','+bblistid from tb where deptid=a.deptid for xml path('')),1,1,'')
from tb a group by deptid
[解决办法]