title: SQL Group by Age Range
body: <p>SQL 2005, 
  I have a table with a column 'ages_c', I need to group the records by age ranges. 
  This is the query that I found on this site and it's getting me 90% there but the 'group by' is erroring, *Invalid column name 'age_range'*</p>
  
  <pre><code> select 
    case
     when age_c &lt;18 then 'Under 18'
     when age_c between 18 and 24 then '18-24'
     when age_c between 25 and 34then '25-34'
   END as age_range, 
   Count(*) as count
   from contacts
   group by age_range
   order by age_range
  </code></pre>
  
  <p>When I group and order by 'age_c' my result is:</p>
  
  <pre><code>  Under 18  1
    18-24 1
    18-24 1
    25-34 1
  </code></pre>
  
  <p>What I want is: </p>
  
  <pre><code> Under 18   1
    18-24 2      
    25-34 1
  </code></pre>
  
  <p>Thanks. </p>