MySQL group date fill in missing dates
<p>I want to get data for each month in the year using group by month. Issue is that if one month has no data then it skips the month. </p>

<p>Is this something I can do within MySQL or should I try and figure out a solution in PHP? A MySQL solution would be the best I think.</p>

<p>Here's the query i'm going with:</p>

<pre><code>SELECT 
  MONTH(date) as g, 
  SUM(gross) AS revenue, 
  ABS(SUM(fee)) AS fee, COUNT(*) AS volume
FROM transactions
WHERE
  date BETWEEN DATE_SUB(NOW(), INTERVAL 1 YEAR) AND NOW() and
  gross &gt; 0 and
  currency = 'USD'
GROUP BY g;
</code></pre>