If I want to cast a decimal, say (12,2) into char so that it is right aligned, is there an easy format string to do so? Right now when I do the cast, it left aligns the number is the resulting char. I am currently using trim, left pad and retrim.
The ANSI CAST drops leading blanks. One alternative is to use the Teradata (non-ANSI) conversion specifier. In the example below, I applied a format to the decimal value to get leading blanks and trailing zeros before coercing the result to character.
create table t3 (a decimal(12,2)); insert into t3 values (1.0);
-- The forum software software removes repeating blanks, so I'll have to demonstrate -- with a hex dump:
.indicdata on select (a(format 'zzzzzzzzzz.99'))(char(13)) from t3;
*** Success, Stmt# 1 ActivityCount = 1 *** Query completed. One row found. One column returned.