title: Why can't I perform an aggregate function on an expression containing an aggregate but I can do so by creating a new select statement around it?
body: <p>Why is it that in SQL Server I can't do this:</p>
  
  <pre><code>select  sum(count(id)) as 'count'
  from    table
  </code></pre>
  
  <p>But I can do</p>
  
  <pre><code>select sum(x.count)
  from
  (
      select  count(id) as 'count'
      from    table   
  ) x
  </code></pre>
  
  <p>Are they not essentially the same thing? How am I meant to be thinking about this in order to understand why the first block of code isn't allowed?</p>