Using Agregate "Count" to return 0 for Null values

R

Rob Allison

I am trying to count entries for 12 periods and have query return 0 when
there are no entries for that period but can't get the language correct.
Please help. SQL follows:

SELECT [tblDatesGS-W].MonthID, Count(PreCountQuery.Expr1) AS CountOfExpr1
FROM [tblDatesGS-W] INNER JOIN PreCountQuery ON [tblDatesGS-W].MonthID =
PreCountQuery.MonthID
GROUP BY [tblDatesGS-W].MonthID;

Thanks
 
D

Douglas J. Steele

Assuming that tblDatesGS-W has entries for each period, try replacing INNER
JOIN with LEFT JOIN.
 
R

Rob Allison

Thank you. That solved the problem.
--
Rob Allison
RCA Enterprises


Douglas J. Steele said:
Assuming that tblDatesGS-W has entries for each period, try replacing INNER
JOIN with LEFT JOIN.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rob Allison said:
I am trying to count entries for 12 periods and have query return 0 when
there are no entries for that period but can't get the language correct.
Please help. SQL follows:

SELECT [tblDatesGS-W].MonthID, Count(PreCountQuery.Expr1) AS CountOfExpr1
FROM [tblDatesGS-W] INNER JOIN PreCountQuery ON [tblDatesGS-W].MonthID =
PreCountQuery.MonthID
GROUP BY [tblDatesGS-W].MonthID;

Thanks
 
Top