title: Changing a SUM returned NULL to zero
body: <p>I have a stored procedure as follows:</p>
  
  <pre><code>CREATE PROC [dbo].[Incidents]
  (@SiteName varchar(200))
  AS
  SELECT
  (  
      SELECT SUM(i.Logged)  
      FROM tbl_Sites s  
      INNER JOIN tbl_Incidents i  
      ON s.Location = i.Location  
      WHERE s.Sites = @SiteName AND i.[month] = DATEADD(mm, DATEDIFF(mm, 0, GetDate()) -1,0)  
      GROUP BY s.Sites  
  )  AS LoggedIncidents
  
  'tbl_Sites contains a list of reported on sites.
  'tbl_Incidents contains a generated list of total incidents by site/date (monthly)
  'If a site doesn't have any incidents that month it wont be listed.
  </code></pre>
  
  <p>The problem I'm having is that a site doesn't have any Incidents this month and as such i got a NULL value returned for that site when i run this proc, but i need to have a zero/0 returned to be used within a chart in SSRS.</p>
  
  <p>I've tried using coalesce and isnull to no avail.</p>
  
  <pre><code>    SELECT COALESCE(SUM(c.Logged,0))
      SELECT SUM(ISNULL(c.Logged,0))
  </code></pre>
  
  <p>Is there a way to get this formatted correctly?</p>
  
  <p>Cheers,</p>
  
  <p>Lee</p>