Calculation in a query

TashaSpicer

Registered User.
Local time
Today, 13:14
Joined
Aug 17, 2009
Messages
17
I have several columns of numbers that I need to add together to get a total number for the amount of a products issued. Ex.

Apples sold Oranges sold Bananas sold Total Fruit sold
5 8 2 ?

The total would be 15, but how do I get it to add across the columns in the query?

Thanks!!
 
This sounds like a normalization issue.

It sounds like you have this:

row apples oranges bananas
1 3 5 6
2 4 6 7
3 5 6 8

What you should have is something like this:

row Quantity FruitType
1 3 apples
2 5 apples
3 6 apples
4 4 oranges
5 6 oranges
6 7 oranges
etc.....

You would indeed have two tables. One table would be something like tblFruitsold, and the other tblFruitType

tblFruitsold
pkFruitsoldID - Autonumber, Primary Key
Quantity
fkFruitTypeID - Number, Foreign Key

tblFruitType
pkFruitTypeID - Autonumber, Primary Key
FruitType- Text

In the relationship screen relate the pk of tblFruitType to the foreign key fkFruitTypeID in tblFruitSold.

Then on a form you can have a combo box for people to select the fruit type when they enter data.

THEN in a query you can use the totals row, and sum funtions.
 

Users who are viewing this thread

Back
Top Bottom