查询的结果用逗号连接 有图
SQL怎样写能变成下面这张图
[解决办法]
create table #table(baomingzy varchar(50),call_user varchar(50))
insert into #table
select '','jiangbingyu' union all
select '','jiangshengnan' union all
select '','menglingjun' union all
select '办公自动化','jiangshengnan' union all
select '初级会计实务','jiangshengnan' union all
select '电脑应用高级班','jiangshengnan' union all
select '海洋自动化精+串','jiangshengnan' union all
select '会计就业直通班','jiangshengnan' union all
select '会计学串讲','jiangshengnan' union all
select '中级会计师','jiangshengnan' union all
select '专升本VF+英语','jiangshengnan'
select distinct
(select stuff((
select ','+baomingzy from #table b where a.call_user=b.call_user
for xml path('')),1,1,''))baomingzy
,call_user
from #table a
baomingzy call_user
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------
jiangbingyu
menglingjun
,办公自动化,初级会计实务,电脑应用高级班,海洋自动化精+串,会计就业直通班,会计学串讲,中级会计师,专升本VF+英语 jiangshengnan
(3 行受影响)