title: Count number of user in a certain age's range base on date of birth
body: <p>I have table user that has <code>user_id</code>, <code>user_name</code> and <code>user_dob</code>.</p>
  
  <p>I want to count how many users that are under 18 year old, 18-50 and over 50.</p>
  
  <p>The Age calculation method need to be improved to calculate exact age but for now I am more interested in finding the method to count</p>
  
  <p>So I tried:</p>
  
  <pre><code>SELECT COUNT ([user_id]) 
  from [user]
  where (DATEDIFF(yy,[user_dob], GETDATE()) &lt; 18)
  UNION ALL
  SELECT COUNT ([user_id]) 
  from [user]
  where (DATEDIFF(yy,[user_dob], GETDATE()) &gt;= 18 AND DATEDIFF(yy,[user_dob], GETDATE()) &lt;=50)
  UNION ALL
  SELECT COUNT ([user_id]) 
  from [user]
  where (DATEDIFF(yy,[user_dob], GETDATE()) &gt; 50)
  </code></pre>
  
  <p>It gives me result like:</p>
  
  <pre><code>(No column name)
  1218
  3441
  1540
  </code></pre>
  
  <p>But I need something like this</p>
  
  <pre><code>Range    | Count
  ----------------
  Under 18 |  1218
  18-50    |  3441
  Over 50  |  1540
  </code></pre>
  
  <p>Any suggestions how to archive above format?</p>