我需要构建一个gorm查询,在
时返回状态字段求和大小写喜欢这个sum(case when status = 0 then 1 else 0 end) waiting_data
我的gorm查询是:
return Product.createCriteria().list() {
resultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP)
projections {
count("id")
property("so.id", "id")
property("so.soNumber", "soNumber")
property("so.dateCreated", "dateCreated")
property("acc.name", "account_name")
property("proj.name", "project_name")
property("gtin", "gtin")
property("status", "status")
property("statusDate", "status_date")
sqlRestriction ("sum(case when status = 0 then 1 else 0 end) waiting_data")
groupProperty("so.id")
groupProperty("so.soNumber")
groupProperty("so.dateCreated")
groupProperty("acc.name")
groupProperty("proj.name")
groupProperty("proj.name")
groupProperty("gtin")
groupProperty("status")
groupProperty("statusDate")
}
可能在grails gorm投影中使用sum(情况......)
怎么做?