access如何update sum合计更新

请问Access如何像下面的SQL语句一样的合计更新啊??
update table1 set Subtotal = (select SUM(amount) from table2 where table1.userid = table2.userid) from table1
请问下access里面怎么实现?

一个语句可能搞不定,不支持update...from,如果使用update子查询,提示操作必须使用一个可更新的操作


update table1 t1,(SELECT sum(amount) AS t, userid
FROM table2
GROUP BY userid)t2
set t1.subtotal=t2.t
where t1.userid=t2.userid


img

update 2个表需要2个真实的表就行,建立统计视图也是提示上面的错误,如果新建表table3存储统计的值,使用update 2个表就行

img

先执行插入操作


insert into table3  SELECT sum(amount) AS t, userid
FROM table2
GROUP BY userid


在执行联合更新就行


update table1 t1,table3 t2
set t1.subtotal=t2.t
where t1.userid=t2.userid


img

img

要加上where条件吧,要不然所有记录都更新为一样的了。

我直接用视图做了统计,没有用这种更新了,试了好多方法都不行。谢谢各位的帮忙