Sum error on select query

K

Keith

Hi

I have created a number of queries which calculate the volume sold per
account for specific products; I am now trying to collate these into one
summary table with a row for each account and the products as column headings.

When I add the first column the output is correct, however, as I add more
columns the figures in preceding columns multiply so that e.g. the figures in
the "CA" column end up 6x higher than they should be. I think this is
something to do with the repeated "Sum" function but I'm not sure how to
amend the query design to avoid this problem and produce the desired output.

I have attached the SQL code below - any help would be much appreciated.



SELECT [Seller info].AccountNumber, Sum([CA M1.SumOfCA]) AS [CA Sales],
Sum([Savings M1.Savings]) AS [Savings Sales], Sum(IIf([Fees M1.Product
Name]<>"Investments",0,[Fees M1.SumOfFees]))) AS [Investments], Sum(IIf([Fees
M1.Product Name]<>"Other",0,[Fees M1.SumOfFees]))) AS [Other]
FROM (([Seller info] INNER JOIN [CA M1] ON [Seller info].AccountNumber = [CA
M1].AccountNumber) INNER JOIN [Savings M1] ON [CA M1].AccountNumber =
[Savings M1].AccountNumber) INNER JOIN [Fees M1] ON [Savings
M1].AccountNumber = [Fees M1].AccountNumber
GROUP BY [Seller info].AccountNumber
 

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