自己改改--2005 create table ym (col1 int, col2 int, col3 varchar(3))insert into ym select 1, 1, 'A' union all select 1, 1, 'B' union all select 1, 2, 'C' union all select 1, 3, 'D' union all select 1, 3, 'E' select a.col1,a.col2, stuff((select ','+col3 from ym b where b.col1=a.col1 and b.col2=a.col2 for xml path('')),1,1,'') 'col3' from ym a group by a.col1,a.col2
2、那段代码的输入输出是怎样的?
create table ym
(col1 int, col2 int, col3 varchar(3))insert into ym
select 1, 1, 'A' union all
select 1, 1, 'B' union all
select 1, 2, 'C' union all
select 1, 3, 'D' union all
select 1, 3, 'E'
select a.col1,a.col2,
stuff((select ','+col3 from ym b
where b.col1=a.col1 and b.col2=a.col2
for xml path('')),1,1,'') 'col3'
from ym a
group by a.col1,a.col2