B
bg17067 via AccessMonster.com
I have this SQL query in Access 2003 and it works perfectly. However, I am
trying to add an additional WHERE statement to the query.
Here is the exisitng query:
SELECT Manufacturer, AccountNumber, Customer, SUM(CurrAmt) AS [Current], SUM
(PrevAmt) AS [Prior]
FROM [SELECT Manufacturer, AccountNumber, Customer, SUM([Shipped Amount]) AS
CurrAmt, 0 AS PrevAmt
FROM Tbl_Commission
WHERE ShippedDate BETWEEN [Enter Current Start Date] AND [Enter Current End
Date]
GROUP BY Manufacturer, AccountNumber, Customer
UNION ALL
SELECT Manufacturer, AccountNumber, Customer, 0 AS CurrAmt, SUM([Shipped
Amount]) AS PrevAmt
FROM Tbl_Commission
WHERE ShippedDate BETWEEN [Enter Prior Start Date] AND [Enter Prior End Date]
GROUP BY Manufacturer, AccountNumber, Customer]. AS X
GROUP BY Manufacturer, AccountNumber, Customer;
I am trying to add an additional WHERE statement of AccountNumber = [Enter
Account Number]. When I try to add that in directly under the other WHERE
statement I get an "invalid bracketing" error.
Any help would be greatly appreciated!!! Thanks in advance!!
Brian
trying to add an additional WHERE statement to the query.
Here is the exisitng query:
SELECT Manufacturer, AccountNumber, Customer, SUM(CurrAmt) AS [Current], SUM
(PrevAmt) AS [Prior]
FROM [SELECT Manufacturer, AccountNumber, Customer, SUM([Shipped Amount]) AS
CurrAmt, 0 AS PrevAmt
FROM Tbl_Commission
WHERE ShippedDate BETWEEN [Enter Current Start Date] AND [Enter Current End
Date]
GROUP BY Manufacturer, AccountNumber, Customer
UNION ALL
SELECT Manufacturer, AccountNumber, Customer, 0 AS CurrAmt, SUM([Shipped
Amount]) AS PrevAmt
FROM Tbl_Commission
WHERE ShippedDate BETWEEN [Enter Prior Start Date] AND [Enter Prior End Date]
GROUP BY Manufacturer, AccountNumber, Customer]. AS X
GROUP BY Manufacturer, AccountNumber, Customer;
I am trying to add an additional WHERE statement of AccountNumber = [Enter
Account Number]. When I try to add that in directly under the other WHERE
statement I get an "invalid bracketing" error.
Any help would be greatly appreciated!!! Thanks in advance!!
Brian