HQL计数语句

时间:2013-11-29 04:09:04

标签: hql aggregate-functions

我有这样的代码

 (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',

2 个答案:

答案 0 :(得分:0)

Select count(app.state) as Confirmed from App app where app.state=2 

答案 1 :(得分:0)

我找到了解决方案

sum(case when app.test=2 then 1 else 0 end) as tested