I use Grails Criteria to output results for a specific domain, want to ask if it is possible to have a group property in an order clause or, in other words, how can I write the following mysql query using Grails criteria?
select
h.name,
count(h.id)
from my_table as h
group by h.name
order by count(h.id) desc;
so far the grails criteria request looks like
def results = MyObject.createCriteria().list{
projections{
groupProperty('name')
countDistinct('id')
}
order(???,'desc')
}
Thanks in advance Rahman
source
share