Discussions
Join the NetSuite community to innovate, connect, and discover what’s next.
SuiteWorld brings thousands of innovators, builders, and leaders together to learn, connect, and shape what’s next. This October, explore how to build a stronger foundation for growth through inspiring keynotes, major product reveals, hands-on sessions, and unforgettable moments—all in one place for our biggest event of the year. Register now
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.