title: Mysql sum of records by month for the last 12 months
body: <p>Hello I'm using this sql query to get the last 12 month records based on month for chart representation:</p>
  
  <pre><code>SELECT DATE_FORMAT(drives.timestamp, "%b") AS Month,
                           DATE_FORMAT(drives.timestamp, "%d-%m-%Y %H:%i:%s") AS Exact_date,
                           drives.departure,
                           drives.destination,
                           drives.route,
                           CONCAT(drivers.name, " ", drivers.surname) as driver,
                           drivers.id as driver_id
                           FROM drives, drivers WHERE drives.driver = drivers.id 
                           AND drives.timestamp &gt; DATE_SUB(now(), INTERVAL 12 MONTH) ORDER BY drives.timestamp Asc
  </code></pre>
  
  <p>however if there are no records for a month it is not included in the result set as expected, and I'm doing a lot of calculations with php to accomplish what I want.</p>
  
  <p>My question is this: Is there a way to retrieve a simple result set with the sum of drives of each month for the last 12 months AND if there are 0 drives for a month it must be also included-shown in the result set.</p>