title: How does one query for count() on a series of ranges at once?
body: <p>I'm trying to compose a breakdown of forum ranks on a phpBB forum.  Forum ranks are defined by your postcount: if you have between 1-9 posts you're level 1; 10-24 and you're level 2; and so on.  (The maximum rank is anything above 2000 posts.)</p>
  
  <p>Right now, my forum rank statistics page is just doing a bunch of dumb queries:</p>
  
  <pre><code>SELECT COUNT(*) from _users WHERE post_count&gt;=1 AND post_count&lt;10;
  SELECT COUNT(*) from _users WHERE post_count&gt;=10 AND post_count&lt;25;
  </code></pre>
  
  <p>... And so on.</p>
  
  <p>The queries run in a few seconds, so I'm really just curious (for future reference) a better way to solve this problem - it feels like there ought to be one query I can run that'll return results akin to this:</p>
  
  <pre><code>rank_id | count
  1       | 5000
  2       | 2000
  ...
  </code></pre>
  
  <p>I do have another table which has a listing of the ranks and the minimum number of posts needed to achieve that rank.  Not sure if that's necessary or if there's a more clever way to write my queries.</p>
  
  <p>I'm using a MySQL DB if that helps any, but I'm much more interested in a cross-database answer.</p>