日期:2014-05-17 浏览次数:20513 次
with tb(col1,col2,col3)
as(
select 'A','A1','Q1' union all
select 'A','B1','Q1 ' union all
select 'B','C1','Q2' union all
select 'C','D1','Q5' union all
select 'C','E2','Q4' union all
select 'C','F2','Q5'
)
select col1+':'+stuff((select ','+col2+'('+col3+')' from tb b where a.col1=b.col1 for xml path('')),1,1,'') from tb a group by col1