sql 内容拼接




select c.report_with_id,ri.entid,



stuff((select ';' + cast(row_number() over(order by t.uuid) as varchar) +'.'
+ cast(isnull(t.maincontent,'') as varchar) from sa_idx_checkspecial t
           where t.report_with_id = c.report_with_id for xml path('')) , 1 , 1 , '') as zynr,
           
    sum(c.question) as question,sum(c.suggestion) as suggestion,sum(c.consult) as consult,
    sum(c.prompt) as prompt,sum(c.suggest) as suggest,sum(c.others) as others
from sa_report_instance ri,sa_idx_checkspecial c 
where ri.uuid=c.report_with_id and ri.rep_period=1 and ri.rep_annual=2015 
and ri.report_code='zd' and ri.report_type=1 

group by c.report_with_id,ri.entid 



查找

使用 SQL的 for xml path来进行字符串拼接

http://www.cnblogs.com/repository/archive/2011/01/18/1938418.html


查找

sql STUFF用法

http://www.cnblogs.com/345563452/archive/2009/10/29/1592048.html





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值