update 客户表 set 总消费金额=(select sum(单次消费金额) from 消费表 where 客户id=客户表.客户id)
update 客户表 a set 总消费金额 =sum(b.单次消费金额) from 消费表 b where a.客户id =b.客户id
update 客户表 set 总消费金额=(select sum(单次消费金额) from ( select 单次消费金额 from 消费表1 where 客户id=客户表.客户id union all select 单次消费金额 from 消费表2 where 客户id=客户表.客户id ) T ) 不知楼主是不是这个意思,消费表是不是按时间生成的
update 客户表 set 总消费金额=(select sum(单次消费金额) from 消费表 group by 消费表.客户id where 客户id=客户表.客户id )
set 总消费金额 =sum(b.单次消费金额)
from 消费表 b
where a.客户id =b.客户id
update 客户表 set 总消费金额=(select sum(单次消费金额) from (
select 单次消费金额
from 消费表1 where 客户id=客户表.客户id
union all
select 单次消费金额
from 消费表2 where 客户id=客户表.客户id
) T
)
不知楼主是不是这个意思,消费表是不是按时间生成的
set 总消费金额=(select sum(单次消费金额) from 消费表 group by 消费表.客户id
where 客户id=客户表.客户id )