title: Reduce SQL statement with sum of col of result
body: <pre><code>select *, 
    (a / 100) as a_calc, 
    (select sum(a_calc) from foo where c = ? and d = ?) as a_calc_sum 
  from foo 
  where c = ? and d = ? 
  order by a;
  </code></pre>
  
  <p>The purpose here is I want to return all rows matching the original query (without the sum) and have mysql calculate the sum of a_calc for me instead of issuing a separate query.  Without the subselect it seems I only get the first row in the query with the correct sum attached.</p>
  
  <p>Any ideas how to reduce the above query?</p>