mssql 实现mysql group_concat 函数效果,多列数据转换为一行数据

SELECT
SECURITY_ID,
stuff(
(
SELECT
',' + CONVERT (VARCHAR(20), NAME)
FROM
neeq_ms_change AS t2
WHERE
t2.SECURITY_ID = t1.SECURITY_ID FOR XML PATH ('')
),
1,
1,
''
) AS rwids
FROM
neeq_ms_change as t1
WHERE
t1.SECURITY_ID = '4993'
GROUP BY
SECURITY_ID

posted @ 2017-08-04 09:13  一路漂泊  阅读(2455)  评论(0编辑  收藏  举报