简体   繁体   中英

Groupby using GORM or MySql

My table has three column

created(Date)
score(int)(value is between 1-3)
id(long)

currently I am using Grails(GORM)

 def listData= DaSes.createCriteria().list([max: 5, order: 'desc', sort: 'created']) { 
            projections {
                groupProperty('created')
                count('id')
            }
        }

[[date,count(of all scores)],[date,count(of all scores),...]

But I want result like this

[[date,count(of all scores),count(score1 for current day),count(score2 current day),count(score3 current day)],....]

Please guide me in this .

This is logically not possible.If you are using Group by on multiple columns then it gives GROUPBY多列结果

And this result is correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM