sql server的拆分和合并

原数据:

 

 

 期望得到:

 

 

 

语法:

SELECT 
    ApplyId
   ,stuff((
        SELECT 
            ','+SplitCostNo 
        FROM CET AS tb01 where tb01.ApplyId=tb02.ApplyId
        FOR xml PATH('')),1,1,'') AS classList 
 FROM  CET AS tb02 
 GROUP BY ApplyId

 

参考链接:https://www.cnblogs.com/fang-beny/p/3255171.html

posted @ 2021-04-15 14:18  顾星河  阅读(199)  评论(0编辑  收藏  举报