我在MS Access中有一个查询表,其中有ItemNumber
和Quantity
字段。我想在表格中添加一个计算字段TotalQuantity
,该字段汇总了相关项目的数量,如下所示:
=====================================
ItemNumber Quantity TotalQuantity
=====================================
INV-0001 10 45
INV-0001 20 45
INV-0001 15 45
INV-0002 5 23
INV-0002 8 23
INV-0002 10 23
INV-0003 4 9
INV-0003 5 9
可以使用哪个公式来添加此计算字段?
答案 0 :(得分:2)
将查询与子查询一起使用:
Select
ItemNumber,
Quantity,
(Select Sum(T.Quantity)
From YourTable As T
Where T.ItemNumber = YourTable.ItemNumber) As TotalQuantity
From
YourTable