How can I get the last 12 months sales subtotals in a table?
<p>I have this code so far which gives me the subtotals for each product for a given month. </p>

<pre><code> &lt;?php
    include("dbaseconn.php"); 




    $query = "SELECT product, SUM(qty) FROM sh_orders GROUP BY product"; 

    $result = mysql_query($query) or die(mysql_error());

    // Print out result
    while($row = mysql_fetch_array($result)){
      echo "&lt;table width='1050'&gt;"  ;
      echo "&lt;td width='400'&gt;";
        echo "". $row['product']. " ";
      echo "&lt;/td&gt;";
      echo "&lt;td&gt;";
      echo "". $row['SUM(qty)']. "" ;
      echo "&lt;/td&gt;";
        echo "&lt;br /&gt;";
    }
    ?&gt;
</code></pre>

<p>TABLE STRUCTURE</p>

<pre><code>CREATE TABLE IF NOT EXISTS `sh_orders` (
  `building` varchar(50) NOT NULL,
  `qty` varchar(5) NOT NULL,
  `product` varchar(50) NOT NULL,
  `order_id` bigint(5) NOT NULL AUTO_INCREMENT,
  `unik` varchar(50) NOT NULL,
  `order_date` varchar(25) NOT NULL,
  `co_id` varchar(20) NOT NULL,
  UNIQUE KEY `unik` (`unik`),
  UNIQUE KEY `id` (`order_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
</code></pre>

<p>I want to show the last 12 months sales - SUM (qty) does that for me, but I need to see each month separately with each product and its total sales for that month. I need this in one table showing each month with each product and total for that month</p>

<pre><code>EXPECTED RESULT
Month:    January 2012    Feb 2012   Marc 2012
Product1: 124                105         76
Product2:  34                 23         56
Product3:  12                  5          6
</code></pre>

<p>I am new to this so please show patience if I ask a million questions.</p>
