title: How do I group by month and year when only having a datetime field?
body: <p>I have a table schema which is essentially a bunch of transaction info with a datetime field</p>
  
  <pre><code>TRANSACTION (&lt; transactionid &gt;, amount, when)
  </code></pre>
  
  <p>I need to generate a monthly total of transactions, which is SUM(amount), but I stumped by what do I group by. Each row from SQL should contain the monthly total (so one row for Jan 09, Feb 09....Jan 2010 and so on). I am thinking that I may have to generate the table by code, but would like to learn if there is a way to resolve this using SQL.</p>
  
  <p>Any help would be appreciated! (Using MySQL 5.3, PHP5)</p>