【问题标题】:How to write sum in combination of case如何结合大小写写总和
【发布时间】:2013-03-09 09:33:23
【问题描述】:

这是我使用休眠的代码,期待这样的事情

SUM( CASE WHEN model.voter.age 
            between '"+18+"' and '"+25+"' 
            THEN 1 ELSE 0 END) as 18ageCount


org.springframework.orm.hibernate3.HibernateQueryException: 
     expecting IDENT, found '18' near line 1, column 325 

我尝试了不同的组合,但不起作用

【问题讨论】:

    标签: mysql spring hibernate hql


    【解决方案1】:

    Expressions 在休眠中用于where 子句。要解决此问题,您需要重写查询

    select sum(1) from model.voter where age between 18 and 25 
    

    【讨论】:

      【解决方案2】:

      只是因为18ageCount这一个而已,我重写了它

      【讨论】:

        猜你喜欢
        • 2018-08-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-14
        • 1970-01-01
        • 2014-07-19
        • 1970-01-01
        • 2012-11-13
        相关资源
        最近更新 更多