title: Query that Counts records with a WHERE clause
body: <pre><code>                SELECT 
                  EmailOfConsumer, 
                  COUNT(EmailOfConsumer) as 'NumberOfOrders',
                  SUM(CAST(Total as money)) as 'TotalValue',
                  (SUM(CAST(Total as money))/COUNT(EmailOfConsumer)) as 'AverageValue'
                  FROM webshop
                  GROUP BY EmailOfConsumer 
                  ORDER BY TotalValue DESC
  </code></pre>
  
  <p>This brings back:</p>
  
  <pre><code>EmailOfConsumer NumberOfOrders  TotalValue                AverageValue
  test                   1              2000000000.10           2000000000.10 
  </code></pre>
  
  <p>I would like to add a search on <code>WHERE NumberOfOrders = '1'</code> </p>
  
  <p>I have tried adding <code>WHERE COUNT(EmailOfConsumer) = '1'</code></p>
  
  <p>but I get this error:</p>
  
  <pre><code>    An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a 
  HAVING clause or a select list, and the column being aggregated is an outer reference.
  </code></pre>