Grails GORM HQL按行查询返回的行数

时间:2017-05-27 05:40:29

标签: grails hql gorm

任何人都可以帮我为以下查询的GORM编写等效的HQL查询:

SELECT count(DISTINCT cast(t.disburse_time AS DATE))
FROM transactions_details t
WHERE (t.status_id = 5 OR t.status_id = 6 OR t.status_id = 7)
ORDER BY t.disburse_time;

1 个答案:

答案 0 :(得分:1)

尝试以下方法:

Transactions_details.createCriteria().list() {
            projections {
                countDistinct( 'disburse_time' )
            }
            'in' ( 'status_id', [5,6,7] )
            order 'disburse_time'
        }