在 HQL select 中使用 CASE 语句 [英] Using a CASE statement in HQL select

查看:39
本文介绍了在 HQL select 中使用 CASE 语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 HQL 中执行以下操作:

Is there any way to do the following in HQL:

SELECT 
    case when flag = true then SUM(col1) else SUM(col2)
FROM 
    myTable

推荐答案

我想你可以 (3.6, 4.3) [内联编辑] ...对于 where 子句:

I guess you can (3.6, 4.3) [inline edit] ...for where-clauses:

简单"情况,case ... when ... then ... else ... end,和搜索"情况,case when ... then ... else ... 结束

"Simple" case, case ... when ... then ... else ... end, and "searched" case, case when ... then ... else ... end

这篇关于在 HQL select 中使用 CASE 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆