【发布时间】:2013-11-29 04:09:03
【问题描述】:
我有这样的代码
(case app.test when 2 then '' end) as tested
在参考此文档http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#queryhql-aggregation后,我正在尝试计算这个 app.state 的数量。
count (case app.test when 2 then 'tested' end) as tested
在此之后我收到类似
的错误unexpected token: case
任何想法
但同样的语句在 mysql 中起作用
COUNT(CASE WHEN app.test= 2 THEN "tested" END) 'tested',
【问题讨论】:
-
我不认为 hql 允许你使用聚合函数计数与 case.. 你可能不得不使用 sql 查询。看this
-
没有 hql 允许聚合函数。我用过它们