【原地址】
for xml path作用:将多行的查询结果,根据某一些条件合并到一行。
例:现有一张表
执行下面语句
select Department, (SELECT Employee+',' FROM People b WHERE b.Department=a.Department For XML Path('')) Student from People as a group by Department
得如下结果