【发布时间】:2018-03-22 06:09:59
【问题描述】:
我正在尝试将列中的一些值连接到单个字段中。
到目前为止,我有以下代码。
SELECT DISTINCT [customer id]
,[customer name]
,STUFF( (SELECT ',' + [description]
FROM [Invoicing].[dbo].[CurrentBillMaster]
ORDER BY [description]
FOR XML PATH('')),
1, 1, '')
,[id]
,[Section]
,[customerpo]
FROM [Invoicing].[dbo].[CurrentBillMaster]
GROUP BY [customer id], [customer name], [description],[qty],
[identifier],[FromDate],[ToDate],[id],[Section],[customerpo]
代码基本上可以工作,但是我想要连接描述,只是为了显示该唯一 [客户 ID] 的描述
非常感谢任何帮助
【问题讨论】:
-
添加样本数据和预期输出以获得更好的答案
标签: sql tsql for-xml-path