Query Sums Too Large

TastyWheat

Registered User.
Local time
Today, 10:39
Joined
Dec 14, 2005
Messages
125
I have a pretty complicated query here. I have a series of stores with sales data. Sometimes I want to consolidate the store information so the total sales of stores {1,2,...,n} would be totaled as a single store. I can do that and show it as a summary, but when I try to compare the totals (differences) from month to month I get bloated numbers. Here's part of my query:

Code:
SELECT Sum(S1.net) AS [Net B], Sum(S2.net) AS [Net A], ......
FROM (SELECT * FROM Sales WHERE Sales.storeNum = 1 OR Sales.storeNum = 6 OR Sales.storeNum = 8) AS S1,
(SELECT * FROM Sales WHERE Sales.storeNum = 1 OR Sales.storeNum = 6 OR Sales.storeNum = 8) AS S2
WHERE S2.date = DateAdd("m",-1,S1.date)
GROUP BY S1.date, S2.date;

I already know the pattern for the enlarged sizes. If I select 3 stores then the totals are multiplied by 3; 4 stores and the total is multiplied by 4. I can give you a fuller query if you think it will help. I only cut out a bunch of extra summations.
 

Users who are viewing this thread

Back
Top Bottom