title: NHibernate - QueryOver criteria appearing in Where instead in Having clause, error
body: <p>I have a problem in QueryOver where using Group by and have some criteria in where clause. Want to move some criteria with SUM() values in Having clause but every time it appears in Where clause and result in error. <code>**Error** ="*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></p>
  
  <pre><code>Conjunction conjunction = Restrictions.Conjunction();
  Conjunction havingconjun = Restrictions.Conjunction();
  
  conjunction.Add&lt;Vendor&gt;(p =&gt; v.Name == "Some Vendor");
  havingconjun.Add(Restrictions.Gt(
     Projections.Sum(Projections.Property(() =&gt; v.Payments),
     Convert.ToDouble(SomeInvoice.Value)));
  
  var reportModels =
              Session.QueryOver&lt;Vendor&gt;(() =&gt; v)
      .Where(conjunction)
      .Where(havingconjun)
      .SelectList(list =&gt; list
                      .SelectGroup(() =&gt; v.Number).WithAlias(() =&gt; vModel.VendorNumber)
                      .SelectGroup(() =&gt; vtypeCode.Code).WithAlias(() =&gt; vModel.VendorType)
                      .SelectGroup(() =&gt; v.Name).WithAlias(() =&gt; vModel.VendorName))
               .TransformUsing(Transformers.AliasToBean&lt;VendorAnalysisReportModel&gt;())
               .List&lt;VendorAnalysisReportModel&gt;();
  </code></pre>
  
  <p><strong>Expected Result:</strong></p>
  
  <pre><code>SELECT 
      V.VENDORNUMBER, V.VENDORTYPE, V.VENDORNAME, SUM(V.PAYMENTS)
   FROM VENDOR V
      WHERE V.NAME = "Some Vendor"
   GROUP 
      BY V.VENDORNUMBER, V.VENDORTYPE, V.VENDORNAME
   HAVING SUM(V.PAYMENTS) &gt; somevalue
  </code></pre>
  
  <p><strong>Getting Now:</strong></p>
  
  <pre><code>SELECT 
      V.VENDORNUMBER, V.VENDORTYPE, V.VENDORNAME, SUM(V.PAYMENTS)
   FROM VENDOR V
      WHERE V.NAME = "Some Vendor" AND
      SUM(V.PAYMENTS) &gt; somevalue
   GROUP 
      BY V.VENDORNUMBER, V.VENDORTYPE, V.VENDORNAME
  </code></pre>