Adnan
Adnan

Reputation: 165

How to add calculated field to Summing up data in MS Access

I have a query table in MS Access having ItemNumber and Quantity fields. I want to add a calculated field TotalQuantity in table which summing up the Quantity of related items just like below:

=====================================
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

Which formula may be used to adding this calculated field?

Upvotes: 0

Views: 60

Answers (1)

Gustav
Gustav

Reputation: 56026

Use a query with a subquery:

Select 
    ItemNumber, 
    Quantity, 
    (Select Sum(T.Quantity) 
    From YourTable As T
    Where T.ItemNumber = YourTable.ItemNumber) As TotalQuantity
From
    YourTable

Upvotes: 2

Related Questions