type  value
a      0
b      1
c      2
d      3
a      2
a      3
d      1
b      0
c      0
得到结果:
type value
a    0,2,3
b    1,0
c    2,0
d    3,1


select [type],
    stuff((select ','+ltrim(value) from tb
           where [type]=[type] for xml path('')),1,1,'') [value]
from tb
group by [type];

  



相关文章:

  • 2021-09-10
  • 2022-03-13
  • 2021-05-24
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-02
  • 2021-11-08
  • 2021-11-04
  • 2021-09-22
相关资源
相似解决方案