Using a CASE statement in HQL select

后端 未结 7 595
再見小時候
再見小時候 2020-12-10 01:51

Is there any way to do the following in HQL:

SELECT 
    case when flag = true then SUM(col1) else SUM(col2)
FROM 
    myTable
相关标签:
7条回答
  • 2020-12-10 02:36

    I facing the same problem in HQL then I solved the following query is

    select CONCAT(event.address1,', ', CASE WHEN event.address2 IS NULL THEN '' ELSE concat(event.address2,', ') END, event.city from EventDetail event where event.startDate>=:startDate and event.endDate<=:endDate;
    
    0 讨论(0)
提交回复
热议问题