聚合不应出现在 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

posted on 2021-12-02 12:17  alibaba保安  阅读(450)  评论(0编辑  收藏  举报