title: MySQL: Use Aliased Fields in Aggregate Functions
body: <p>I have a SQL statement similar to this:</p>
  
  <pre><code>SELECT COUNT(*) AS foo, SUM(foo) AS foo_sum FROM bar
  </code></pre>
  
  <p>But MySQL doesn't allow this because foo is an alias. Does anyone have an idea of how this could be accomplished in SQL?</p>