title: Grails createCriteria group by
body: <p>How can I get something like this MYSQL query with createCriteria in grails?</p>
  
  <pre><code>    SELECT * 
        FROM engine4_user_fields_values
       WHERE field_id = 31 OR field_id = 24 
    GROUP BY item_id;
  </code></pre>
  
  <p>It works fine if I use something like this:</p>
  
  <pre><code>def items = items_c.list{
          'in'('fieldId',field_ids)
          projections{
              groupProperty("itemId")
          }
      }
  </code></pre>
  
  <p>But I need to define order, max and sort field like this:</p>
  
  <pre><code>def items = items_c.list(max:5, sort:"itemId", order:"desc"){
          'in'('fieldId',field_ids)
          projections{
              groupProperty("itemId")
          }
      }
  </code></pre>
  
  <p>But this gets me different rows with the same 'item_id'</p>
  
  <p>What can I do?</p>