title: TSQL COUNT show 0 when no row returned
body: <p>I have one table, <strong>Documents</strong>, that lists all documents and various information about them.  What I'm trying to do is, for a select group of authors, get a count of all documents they've authored in the past year.  For each document, we have a column to store the Author name and ID.  </p>
  
  <p>I am currently getting what I want with the query below, but my problem is I also need to list all authors that haven't authored any documents.  (So, for the <strong>Number of Docs Signed</strong> column they'd have a zero value)  Here's what I have now:</p>
  
  <pre><code>SELECT 
  [AuthorID] As "Author ID",
  RTRIM([AuthorFirstName]) + ' ' + RTRIM([AuthorLastName]) AS "Author", 
  COUNT(Document.ID) AS "Number of Docs Authored"
  
  FROM Document
  
  WHERE   [CompletedStatus] = 'Yes' 
  AND     [AuthorID] IN (&lt;list of author ID's&gt;) 
  AND     [CompletedOn] &gt;= DATEADD(d, -365, getdate())
  
  
  GROUP BY [AuthorID], [AuthorFirstName], [AuthorLastName]
  
  ORDER BY [Number of Docs Signed] DESC
  </code></pre>
  
  <p>From reading around on SO I know I think I need some kind of subquery that I can join in order to show a '0' when there are no rows returned by COUNT.  But for the life of me I can't figure out how to do it.  I'm pretty sure it needs to be something like <a href="http://lichao.net/eblog/how-to-display-0-in-conditional-group-by-report-in-count-sql-query-200808164.html" rel="nofollow">this</a>.</p>