I have two tables one with 2000 rows another with 20000, The problem I am having is that the values I am pulling from my smaller table, Forecasts, when joined with my larger table gets massively multiplied by the other table it seems.
What is the best way to join two tables with unequal tables?.
The query I used is below.
SELECT WalmartCommit.Column1, WalmartCommit.Style, WalmartCommit.Short, WalmartCommit.[Product Line] AS Expr1, WalmartCommit.Gender, Sum(WalmartForecast.[Total Units]) AS Forecast, Sum(WalmartCommit.[Total Units]) AS Current_Commits, Forecast-Current_Commits AS Variance INTO WalmartForecastVsCommit
FROM WalmartCommit LEFT JOIN WalmartForecast ON WalmartCommit.[Product Line] = WalmartForecast.[Product LIne]
WHERE (((WalmartCommit.Gender)="MENS" Or (WalmartCommit.Gender)="Big Mens"))
GROUP BY WalmartCommit.Style, WalmartCommit.Short, WalmartCommit.[Product Line], WalmartCommit.Gender, WalmartCommit.Color, WalmartCommit.Column1
ORDER BY WalmartCommit.Style;
I have broken down this query to find the best way of completing this task through trial and error but have been unsuccessful..
Comments
Post a Comment