TOPIC

磷光与烟火逆流

一个敲代码的程序猿

SQL Server实现group by 之后 聚合操作之拼接结果

使用 stuff函数

select field1, stuff((select ','+field2 from table t where l_id in (1,2,3,4,5,6,7,8,9) and t.l_id=s.l_id for xml path('')), 1, 1, '')  field2 
from table s where l_id in (1,2,3,4,5,6,7,8,9)
group by l_id
posted @ 2021-06-10 16:28  Jacobyang  阅读(580)  评论(0编辑  收藏  举报