Ms-access – sql statement in access that group items and count their sum

ms access

I would like to write an sql statement in microsoft access that group items and count their sum

My table is like below :

id : Auto-Increment
Items : String
Quantity : Number

Eg :

id | Items | Quantity
1 | A | 10
2 | B | 5
3 | A | 10
4 | C | 20
5 | C | 20
6 | A | 10
7 | C | 20
8 | B | 5
9 | B | 5

Expected result is

id | Items | Quantity
1 | A | 30
2 | B | 15
3 | C | 60

Best Answer

I'm guessing the id column is actually not important in your expected result. In which case, you just need to do a grouping and a summation:

select Items, sum(Quantity) as TotalQty
from MyTable
group by Items