Discussions
SQL Formula
Can anyone tell me where I have gone wrong with this expression?
(((DECODE(TO_CHAR({custrecord_mth_date},'MMYYYY'), TO_CHAR(ADD_MONTHS({today},-2),'MMYYYY'),({custrecord_mth_tot_ramp_hrs}),0))
-(DECODE(TO_CHAR({custrecord_mth_date},'MMYYYY'), TO_CHAR(ADD_MONTHS({today},-14),'MMYYYY'),({custrecord_mth_tot_ramp_hrs}),0)))/NULLIF(DECODE(TO_CHAR({custrecord_mth_date},'MMYYYY'), TO_CHAR(ADD_MONTHS({today},-14),'MMYYYY'),({custrecord_mth_tot_ramp_hrs}),0),0))
When I run it as a Formula (numeric), I'm getting -1 on all records.
Following is actual data and what I am trying to accomplish:
(460.27 - 330.46) / 330.46 = 39.3%
When I run the two pieces of the formula separate (460.27 - 330.46) and retrieving the 330.46, the results are fine. When I add the division between the 2 sets of data is when I'm getting inaccurate results.