Suming columns

N

Niall

I am trying to find the sum of two columns that need to
be multiplied together.
For example
Column 1 Column 2
5 4
2 1
3 6

The summed amount should be 40.

I am attempting to do this by adding a third column that
multiplies the first two columns together, and changing
the column 'Total' type to 'Sum', but for some reason,
the number it generates is much larger than it should
be. Does anyone know why this is?

Note: To sum the two column's together, I have an IIF
statement that filters out dates older than a year (i.e.
if Order_Date > 1 year ago, then print 0, else multiply
Column 1 and Column 2) - that could be causing problems...
 
J

Joe Harman

Couldn't resist trying to solve this, however, I'm
certainly not one of the experts. I created a third
column named Product, i.e., Product: [Col1]*[Col2]. Then
I clicked the Sum button to get the Total Row in the QBE
grid and changed Product from Group BY to SUM. At this
point, you can either delete the Col1 and Col2 Fields
from the grid (if they are there) or change them to SUM
also. I deleted them. I got 40 when I ran the query.
You might leave Col1 and Col2 on the grid with Group By
to see what the individual rows are giving.

The Access SQL looks like this.
SELECT Sum([Col1]*[Col2]) AS Product
FROM Table4;

Joe Harman
Retired but still interested.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top