Converting DECIMAL to VARCHAR in Teradata

If you want to convert DECIMAL to VARCHAR type, make sure how you want to get the output.

1. Output with rounding
SELECT
CAST( CAST( 22.51 AS FORMAT 'Z(I)' ) AS VARCHAR(30) )

Output:
23

SELECT
CAST( CAST( 22.49 AS FORMAT 'Z(I)' ) AS VARCHAR(30) )

Output:
22


2. Without rounding (recommended)
SELECT CAST(22 AS VARCHAR(20))
SELECT CAST(22.49 AS VARCHAR(20))

Output: (Actual value)
22
22.49