title: SQL Sum() - 0 in field excluding row from aggregation?
body: <p>Consider the following query:</p>
  
  <pre><code>$query = "
  SELECT a_orders.id, a_orders.billing,
     SUM(a_order_rows.quant_refunded*a_order_rows.price*((100-a_orders.discount)*.01)) as refund_total,
     SUM(a_order_rows.quant*a_order_rows.price*((100-a_orders.discount)*.01)) as order_total 
  FROM a_order_rows JOIN a_orders 
  ON a_order_rows.order_id = a_orders.id 
  WHERE a_order_rows.quant_refunded &gt; 0 
  GROUP BY a_orders.id, a_orders.billing 
  ORDER BY a_orders.id DESC 
  LIMIT 50";
  </code></pre>
  
  <p>The two uses of SUM() are attempting to aggregate the order total and the total amount that has been refunded. They are coming out correctly when when the quant_refunded field is not 0... for example take this data (excluding primary key, item_id for simplicity's sake, assuming each row is a unique item):</p>
  
  <pre><code>Table: a_order_rows
  Fields: order_id, quant, quant_refunded
  1, 1, 1
  1, 2, 1
  2, 1, 1
  2, 1, 0
  </code></pre>
  
  <p>In the case of "order 1" the two aggregations are different and behave as expected. But for "order 2" the two numbers are coming out the same - both numbers are what I am expecting refund_total to be. It appears that the row with "0" in quant_refunded is being excluded from the order_total aggregation.</p>
  
  <p>Hopefully this is explained thoroughly enough. Please let me know if you need more info and I will revise. THANKS!</p>