0

Hi All,

select CAST(MIN(column_1) AS DECIMAL(10,2)) Days from tale_1

I get output as 13.09 13.30 31.00

Can anybody let me know how to get rid of the zero after the decimal point I need output as 13.09 13.3 31

REgards,

flag

1 Answer

1

Not the cleanest solution and the resulting field is a character data type, but for display purposes it should suffice:

CREATE VOLATILE TABLE MyTest, NO LOG
  (ColA Decimal(5,2) NOT NULL)
PRIMARY INDEX (ColA)
ON COMMIT PRESERVE ROWS
;

INSERT INTO MyTest VALUES (13.01);
INSERT INTO MyTest VALUES (33.00);
INSERT INTO MyTest VALUES (24.3);

SELECT ColA
     , CAST(ColA AS decimal(5,2) FORMAT 'ZZZ.ZZ') AS Test
     , TRIM(BOTH '.' FROM TRIM(BOTH '0' FROM ColA)) AS TEST2
FROM MyTest;

For more information on the format clause check out the Data Types and Literals book in the Teradata manuals. Hope this helps.

link|flag

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.