title: How to get the sum of values by month vice using mysql
body: <p>I would like to get sum of total price from the below tables by month from to month to .Example : Jan to Mar How to get the name of the month as well sum of the particular month total. I totally confused with this.Anyone please help me. I'm passing the input like '04-2014' to '05-2014'</p>
  
  <p><strong>Sale table</strong></p>
  
  <pre><code>id_sale date       time
    1     2014-05-05 12.30 am  
    2     2014-05-06 10.30 am 
    3     2014-05-25 12.30 am   
  </code></pre>
  
  <p><strong>Sale Product table</strong></p>
  
  <pre><code>   id_sale_product id_sale price  quantity  id_product
        1              1     10.00   1           1
        2              1     20.00   1           2
        3              2     20.00   3           5
        4              3     20.00   4           6
  </code></pre>
  
  <p>I want to filter by date in sale table and get the sum of the price * quantity = total for every date ie,2014-05-05,2014-05-06..etc</p>
  
  <p>I have tried below query</p>
  
  <pre><code>$query = 'SELECT sp.`id_product_type`,sp.`id_product`,sp.`quantity`,sp.`price`,s.`date`,SUM(sp.`price` * sp.`quantity`) AS total
                FROM `'._DB_PREFIX_.'sale_product` sp
                LEFT JOIN '._DB_PREFIX_.'sales s ON (sp.id_sale = s.id_sale) 
                WHERE DATE_FORMAT(s.`date`, "%m-%Y") BETWEEN "'.$monthFrom.'" AND "'.$monthTo.'"';
  </code></pre>
  
  <p>The output should be :</p>
  
  <pre><code>Example: Month
  January Rs. 2,00,000
  Feburary    Rs. 2,20,000
  </code></pre>