title: Order by sum(value) sql
body: <p>I am trying to get a list of blog_id and the sum of donations on that blog id from a table called donations. And I want to order it by the sum of donations. Basically I want to produce a list of blogs ranked by donations. Blogs are held in a different table referenced by blog_id.</p>
  
  <p>This is what I have been trying but all it does is sum up all donations and produce 1 row. I don't understand what I did wrong here!</p>
  
  <pre><code>$donations_result = mysql_query("SELECT blog_id, sum(amount) FROM donations ORDER BY sum(amount)");
  </code></pre>
  
  <p>Donations table is a series of blog_ids and individual donations. So something like this:</p>
  
  <p>blog_id--donation<br>
  1 ----------26<br>
  1 ----------1<br>
  2 ----------24<br>
  2 ----------12<br></p>