sql 代码
- SQL code
select SUM(buyNumber) as zongshu,offer_id from dbo.crm_customer_offer_detail where offer_id in(select offer_id from dbo.crm_customer_offer) group by offer_id
我要把查询出的值 更新到 领一张表
假如 另一张表 有两列,一列 是要更新字段, 另一个是和 查询出的 offer_id值的关联字段(算是条件),这样的update 怎么写呢
求解 。。。先谢谢啦
------解决方案--------------------
- SQL code
update tbset value=t.zongshufrom(select SUM(buyNumber) as zongshu,offer_id from dbo.crm_customer_offer_detail where offer_id in(select offer_id from dbo.crm_customer_offer) group by offer_id) twhere tb.offer_id=t.offer_id