in Teradata, when cast a decimal to char directly,
the result will show out with a padding dot at the end of the number
eg. the following query will results '123.'
select cast(123. as varchar(10))
the annoying dot can be dealed by cast to Z(I) format
select cast(cast(123. as format 'Z(I)') as varchar(10))
that will bring us the desired results '123'
cast decimal to integer can also do the same thing,
select cast(cast(123. as integer) as varchar(10))
but must take care of the lenth of the decimal number
because the integer can only accommodate numbers from -2,147,483,648 through +2,147,483,647. and when cast to Z(I) the max number can be 9999999999.
No comments:
Post a Comment