Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
v2.6.1
-
None
-
None
Description
Hi,
When we use sum over a case statement, it works when the field is of a certain type like decimal(19,3). But the same fails when used with integer field:
This works:
select sum(case when balance_indicator='1' then cyc_xxx_balanceadbavg else 0 end) , balance_indicator from fct_profit_table_quarterly
group by balance_indicator
Whereas the below sql fails
select sum(case when balance_indicator='1' then accountmonthsopen else 0 end) , balance_indicator from fct_profit_table_quarterly
group by balance_indicator
with the error message:
java.math.BigDecimal cannot be cast to java.lang.Integer while executing SQL: "select sum(case when balance_indicator='1' then accountmonthsopen else 0 end) , balance_indicator from fct_profit_table_quarterly group by balance_indicator LIMIT 50000"
The difference between 1st sql and 2nd sql being - in the first query the metric used in the case statement is of decimal(19,4) and the metric used in 2nd statement is of type int.
Kindly help