grails - count and group by using ExcecuteQuery -
how count number grouping activationdate?
i tried query
def mapquery6= new hashmap() def query6 = "select count(al.id) totalcount,al.activationdate card al , to_days(al.activationdate) > to_days(:from) , to_days(al.activationdate) <= to_days(:to) grouping al.activationdate " mapquery6.from = params.from def = new date().parse('dd/mm/yyyy hh:mm:ss', params.to+ " 05:00:00") to.setdate(to.getdate() + 1) mapquery6.to = println "query 6 = "+query6 def activecard = card.executequery(query6,mapquery6)[0] println "activecard = "+activecard
i want result
if iam using group al.activationdate
the result when printed
activecard = [1, 2014-06-17 20:27:11.0]
and if without group al.activationdate
result
activecard = [6, 2014-06-27 20:27:11.0]
so want ge count number every month.. illustration 2014-07-xx have 3 count, 2014-06-xx 2, , 2014-05-xx 1
try grouping month like
group month(al.activationdate)
grails groovy gorm
No comments:
Post a Comment