然后,我创建了一个查询,该查询为我提供了每个代码和IBAN的SumOfAmount。查询结果:
这是我使用的查询:
SELECT Tabella.CODE, Tabella.IBAN, Sum(Tabella.AMOUNT) AS SumOfAMOUNT FROM Tabella GROUP BY Tabella.CODE, Tabella.IBAN;
现在,我尝试在表格的“ SUMAMOUNT”列中写入每个“ CODE”和“ IBAN”的金额总和,但我无法达到此目的。
我想要这样的东西:
你能帮助我吗?我正在使用MS ACCESS。
预先谢谢你!
答案 0 :(得分:2)
使用相关子查询:
select t.*,
(select sum(t2.amount)
from tabella as t2
where t2.code = t.code and t2.iban = t.iban
) as summaount
from tabella as t;
编辑:
要更新该列,然后将update
与相关的子查询一起使用:
update tabella
set summacount = (select sum(t2.amount)
from tabella as t2
where t2.code = tabella.code and t2.iban = tabella.iban
);