All Forums Analytics
NMadson-3173 44 posts Joined 09/06
14 Sep 2006
simple formatting question

How do I force Teradata to give me decimal values? I've tried a number of other FORMAT variations beyond the example below and I can't get the mantissa to display other than my "123.45" calculation.TIA,NMadsonSelect emp_id, NumAccts, 123.45/NumAccts as NewNum, 15/NumAccts as NewNum2, 15/NumAccts (FORMAT 'ZZ9.99') as NewNum3From t_empWhere emp_id In ('26','00000683422');EMP_ID NumAccts NewNum NewNum2 NewNum326 37 3.34 0 0

15 Sep 2006

if you want to see a number in decimal format cast the numbercast(10 as decimal(5,2))if you have divisions thencast(15 as decimal(5,2))/NumAccts as NewNum2this should display decimal values.Select emp_id, NumAccts, 123.45/NumAccts as NewNum,cast(15 as decimal(5,2))/NumAccts as NewNum2,15/NumAccts (FORMAT 'ZZ9.99') as NewNum3From t_empWhere emp_id In ('26','00000683422');

XTUPIE 42 posts Joined 11/05
26 Oct 2006

HiThe CAST works best but you can also use the FORMAT option as follows:Select emp_id, NumAccts, 123.45/NumAccts (decimal(6,4))as NewNum,15/NumAccts (decimal(6,4))as NewNum2,15/NumAccts (decimal(6,4)) as NewNum3From t_empWhere emp_id In ('26','00000683422');

Regards
Divvy

sachinp17 53 posts Joined 11/06
15 Nov 2006

Hi,Use cast it will work fine.Select emp_id, NumAccts, 123.45/NumAccts(decimal(10,2)) as NewNum,15/NumAccts(decimal(10,2)) as NewNum2,15/NumAccts(decimal(10,2)) as NewNum3From t_empWhere emp_id In ('26','00000683422');

sachinp17 53 posts Joined 11/06
15 Nov 2006

Hi,Use cast it will work fine.Select emp_id, NumAccts, 123.45/NumAccts(decimal(10,2)) as NewNum,15/NumAccts(decimal(10,2)) as NewNum2,15/NumAccts(decimal(10,2)) as NewNum3From t_empWhere emp_id In ('26','00000683422');Regds,sachin

You must sign in to leave a comment.