DATA CONVERSION (%)

UDA

DATA CONVERSION (%)

This line of code is dividing two previous columns in my table and displaying the result as a %. However, if the correct answer to the division is 58.75% the calculation is displaying the result as 58.00%. This is throwing all my results off.


CAST((COALESCE(PAYPAL.PP_GMB_AUD,0)) AS DEC (18,2)) / CAST((COALESCE(TOTAL.TOTAL_GMB_AUD,0)) AS DEC (18,2)) AS PP_GMB_CONV


Can someone suggest how the results get displayed as they should.

THANKS - dbread007
2 REPLIES
Teradata Employee

Re: DATA CONVERSION (%)

Looks like something is casting as integer. You must have left something out of the code you included - calculating a percent would result in .58 and not 58.0. Are you multiplying by 100? If so be sure to case the literal 100 as decimal.
Teradata Employee

Re: DATA CONVERSION (%)

As Jeff pointed out your calculation is giving 0.5875 but casetd as decimal ( 18,2) which is 0.58 and this multiplied by 100 or 100.00 will give you 58%. better try castingas float to get accurate answers.