聚合不应出现在 UPDATE 语句的集合列表中。 使用临时表修改数据

create table #ACRTA(sumall numeric ,name varchar(50))


insert into #ACRTA(sumall ,name) select (sum(应收金额蓝)-sum(应收金额红))as 本年累计应收本币,客户 from(
select sum(TA029) AS 应收金额蓝,0 AS 应收金额红,TA004 as 客户 from ACRTA where TA079=1
group by TA004
union all
select 0 AS 应收金额蓝,sum(TA029)+sum(TA042) AS 应收金额红,TA004 as 客户 from ACRTA where TA079=2
group by TA004
)a group by 客户 


--执行修改语句
update t set t.Number5=e.sumall from CRM_Interunit t , #ACRTA e where t.SerialNumber=e.name

上一篇:阿里云 centos 环境配置与 django 部署


下一篇:python day22