title: SQL View to show interval of 12 months and by year
body: <p>Right now one of the other programmers wrote this view to show interval of 6months. How do i write this so that it shows interval of 12 months grouped by month but only for year 2011</p>
  
  <p>I'd like to copy it for a separate view of 12 months grouped by month but only for year 2012</p>
  
  <pre><code>CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` 
  SQL SECURITY DEFINER VIEW `vw_dash_bymonth`AS
  select 
    month(from_unixtime(`tbl_services`.`datetime`)) AS` month1`,
    date_format(from_unixtime(`tbl_services`.`datetime`),'%Y') AS` year1`,
    date_format(from_unixtime(`tbl_services`.`datetime`),'%d') AS `day1`,
   `tbl_services`.`datetime` AS `realdate`,sum(`tbl_services`.`gallons`) AS `gallons`,
   count(0) AS `service`,
   round(avg(`tbl_services`.`gallons`),1) AS `average`
  from `tbl_services`
  where (from_unixtime(`tbl_services`.`datetime`) &gt; (now() - interval 6 month))
  group by month(from_unixtime(`tbl_services`.`datetime`))
  </code></pre>