bobunknown
Registered User.
- Local time
- Yesterday, 19:58
- Joined
- May 25, 2018
- Messages
- 77
Hi all,
I Have a database for bin collections and I need to know the total number of collections for each bin. The code below works and return the sum of all collections for all bins with a Size ID of 1.
However when I try to add the code below, to see the sum of collections for bins with a size ID of 2 I get a syntax error
This is odd as the following code works perfectly to count the total number of bins that we have out. I have tried to follow it as near as possible to get the answer but I cant understand why there is such a difference between the was SUM and COUNT are formatted.
Any help would be appreciated.
I Have a database for bin collections and I need to know the total number of collections for each bin. The code below works and return the sum of all collections for all bins with a Size ID of 1.
Code:
SELECT DISTINCT SUM (Collections) AS Total120
FROM Bins
WHERE (((Bins.[Bin Size ID])=1));
Code:
SELECT DISTINCT SUM (Collections) AS Total120
FROM Bins
WHERE (((Bins.[Bin Size ID])=1)),
SELECT SUM (Collections) AS Total140
FROM Bins
WHERE (((Bins.[Bin Size ID])=2));
Code:
SELECT DISTINCT (SELECT COUNT(*)
From Bins
WHERE ([Bin Size ID] = 1)
) AS Total_120, (SELECT COUNT(*)
From Bins
WHERE ([Bin Size ID] = 2)
) AS Total_140, (SELECT COUNT(*)
From Bins
WHERE ([Bin Size ID] = 3)
) AS Total_240, (SELECT COUNT(*)
From Bins
WHERE ([Bin Size ID] = 4)
) AS Total_360, (SELECT COUNT(*)
From Bins
WHERE ([Bin Size ID] = 5)
) AS Total_660, (SELECT COUNT(*)
From Bins
WHERE ([Bin Size ID] = 6) OR ([Bin Size ID] = 7)
) AS Total_1100
FROM Bins;