title: SQL Join and Count can't GROUP BY correctly?
body: <p>So let's say I want to select the ID of all my blog posts and then a count of the comments associated with that blog post, how do I use GROUP BY or ORDER BY so that the returned list is in order of number of comments per post?</p>
  
  <p>I have this query which returns the data but not in the order I want?  Changing the group by makes no difference:</p>
  
  <pre><code>SELECT p.ID, count(c.comment_ID) 
  FROM wp_posts p, wp_comments c 
  WHERE p.ID = c.comment_post_ID 
  GROUP BY c.comment_post_ID;
  </code></pre>