title: Average of subquery in GORM
body: <p>I have a table T with columns A &amp; C, from which I would like to retrieve an average count like so:</p>
  
  <pre><code>select avg(AC) as AV
  from
  ( 
   select A, count(1) as AC
   from T
   where C = 1
   group by A
  )
  </code></pre>
  
  <p>How do I accomplish this in GORM?  GRAILS version 2.2.0  I tried following the documentation but there are no good examples.  I couldn't even get the subquery to work :(</p>
  
  <h1>Update</h1>
  
  <p>I was able to get the count portion to work.  Still now sure how to get the average since I don't know how to select from a query.</p>
  
  <pre><code>def tc = T.createCriteria()
  
  def tCounts = tc.buildCriteria {
      and {
          eq 'C', 1
      }
      projections {
         groupProperty 'A'
         rowCount('AC')
      }
  }
  </code></pre>