title: How to filter the total sales record every month using sql query?
body: <p>I am generating a sales report and I am having a hard time with the query. I am not really good in query. I hope you can help me with this. Ok here it is.</p>
  
  <p>I have a sales table. And the structure is like this
  EX:</p>
  
  <pre><code>product_id       name             date_purchased
  1                apple          2014-01-03 12:00:59
  2                orange         2014-01-05 10:12:20
  3                banana         2014-02-01 09:25:01
  4                mango          2014-02-20 18:13:25
  5                stawberry      2014-02-28 13:14:30
  6                jackfruit      2014-05-26 08:16:31
  7                grapes         2014-11-03 09:25:21
  8                guava          2014-12-25 10:15:45
  </code></pre>
  
  <p>Now I want to count the item purchased every month
  My output result should be like this</p>
  
  <p>2,3,0,0,1,0,0,0,0,0,1,1</p>
  
  <p>2 represents Jan,
  3 represents Feb,
  etc...</p>
  
  <p>My query looks like this but I know it is wrong.. :(</p>
  
  <pre><code>SELECT COUNT(product_id) FROM sales_table GROUP BY date_purchased
  </code></pre>
  
  <p>How can I do that using a query? Or should I make a PHP function for this?</p>