22,207
社区成员
发帖
与我相关
我的任务
分享
--开始查询
select cust_num,compCode,product=stuff((select ','+name from tpm
where t.cust_num=cust_num for xml path('')),1,1,'')
from info t
--测试结果
/*
cust_num compCode product
-------- ----------- -----------------------
a 20000001 电脑,电视机
b 20000002 电视机,电冰箱,洗衣机
*/