sql server在一个字段相同值时,另一个字段结果拼接

如下字段红框里的信息都一样的,通过转换实现字段拼接


SELECT formmain_id,(SELECT field0040+';' FROM formson_5489 WHERE formmain_id=A.formmain_id FOR XML PATH('')) AS gjgzsx FROM formson_5489 A GROUP BY formmain_id order by 1

 

posted @ 2018-02-26 17:25  明镜非台  阅读(871)  评论(0编辑  收藏  举报