SELECT SUM(IIF([SendDate]=#2/12/2013# AND MailerID = 1, IIF(TotalCount = null, 0, TotalCount), 0)) AS MailCount
FROM MailReport
Return 0 for no rows returned using SUM and IIF in MS Access
Question
I am looking for a way to return 0 as result for a SQL Query in MS Access when no rows are returned. Following is my query:
SELECT SUM(IIF(TotalCount = null, 0, TotalCount)) AS MailCount FROM MailReport WHERE [SendDate]=#2/12/2013# and MailerID=1
Here the Column TotalCount
is number type and works fine for a query that returns some result. But in case for example date 2/13/2013
has no records, it would simply return a blank
row that is nither 0
nor null
. How do I return a 0 for this row.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow