Using a CASE statement in HQL select

lomaxx picture lomaxx · Jan 19, 2009 · Viewed 85.1k times · Source

Is there any way to do the following in HQL:

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

Answer

Henrik Paul picture Henrik Paul · Jan 19, 2009

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

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