Skip to Content
0
Former Member
Apr 25, 2014 at 05:26 PM

CE_CALC issue when division results in < 0

32 Views

I have a calc view that has 2 sql statements getting counts and then I need to divide one by the other and * 100 to get the percentage. When I use CE_CALC and the result of the division is < 0 (even if I then multiply by 100) my result is always 0. If the result of the division is positive, it works fine. I have also replaced the variables with actual integer values and the result is the same.

This always results in 0 as long as TOTALSHIPPEDBYFCD is < TOTALFCDTODAY:

var5 = CE_PROJECTION(:var4, ["TOTALFCDTODAY", "TOTALSHIPPEDBYFCD",

CE_CALC('(("TOTALSHIPPEDBYFCD" / "TOTALFCDTODAY") * 100)',

decimal(10,2)) AS "PERCENTSHIPPEDBYFCD"]);

This works but I would rather use the CE functions:

var5 = SELECT TOTALFCDTODAY, TOTALSHIPPEDBYFCD,

cast((TOTALSHIPPEDBYFCD)/(TOTALFCDTODAY)*100 as decimal(10,2)) as PERCENTSHIPPEDBYFCD

FROM :var4

;

Do you think this is a bug?

Thanks,

Amy