score:0

I believe you want the following:

case WHEN COUNT(Practice) is null THEN '0' ELSE COUNT(Practice) END AS 'Total Enquiries'

score:0

Hmmm . . . You should keep the types the same:

SELECT dc.dateasdate,
       (case WHEN dc.dateasdate is null THEN 0 ELSE COUNT(Practice) END) AS TotalEnquiries,
       dp.practice,
       de.Origin

However, the date is showing as NULL because the value is NULL in the original data. What value do you want to show in this case?

EDIT:

You can use COALESCE():

SELECT COALESCE(dc.dateasdate, '2016-04-03')
       (case WHEN dc.dateasdate is null THEN 0 ELSE COUNT(Practice) END) AS TotalEnquiries,
       dp.practice,
       de.Origin
. . . 

However, I suspect that the LEFT JOIN is not what you really want.


More questions

More questions with similar tag