title: How to get an average of a hasMany instance property in grails domain classes?
body: <p>I have two classes in Grails application ,<strong>Employee</strong> has hasMany(one To Many relations) for another class called <strong>Vote</strong></p>
  
  <pre><code>class Employee {
     String employeeName   
     static hasMany = [votes:Vote]
  }
  </code></pre>
  
  <p>and vote class has voteRank integer property, and all employees vote on scale of 1-10 and every employee contains list of these votes given by other employees</p>
  
  <pre><code>class Vote {
     Integer voteRank
     static belongsTo =[employee:Employee]
  }
  </code></pre>
  
  <p>How do I get the avg of all votes given per employee. This can be solved in SQL by using group by clause. But i am looking for grails domain mapping and gorm oriented answer for this problem.</p>