title: How to give default values for the SUM() and COUNT() if no data exist in MySQL query which uses GROUP BY?
body: <p>I am using following query which works fine for me except one problem</p>
  <pre><code>SELECT f.period                            AS month,
         SUM(p.revenue * ((100-q.rate)/100)) AS revenue,
         COUNT(DISTINCTq.label)              AS tot_stmt 
  FROM files f, reports p, rates q,albums a
  WHERE f.period IN ('2010-06-01','2010-05-01','2010-04-01','2010-03-01') 
    AND f.period_closed = TRUE
    AND q.period = f.period
    AND a.id = q.album_id
    AND p.file_id = f.id
    AND p.upc = a.upc
    AND p.revenue IS NOT NULL
  GROUP BY month
  ORDER BY month DESC;
  </code></pre>
  <p>O/P =&gt;</p>
  <blockquote>
  <p>month             revenue    
    tot_stmt <br></p>
  <p>2010-06-01      10.00             2
  <br> 2010-05-01      340.47        2 <br></p>
  </blockquote>
  <p>I want result like following:</p>
  <blockquote>
  <p>month             revenue    
    tot_stmt <br></p>
  <p>2010-06-01      10.00             2
  <br> 2010-05-01      340.47        2 <br>
  2010-04-01      0.00       
         0 <br> 2010-03-01      0.00   
          0 <br></p>
  </blockquote>