Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

CASE Statement -- CASE - response (2) by Adharssh

$
0
0

Hi Jackson,
Your query is that. You are having an Table with column as A and i am having Sample like this,
'0  ','ABC','DEF',etc. I should get the output as 
NULL,ABC,DEF. Either the Zeros should be replaced to Null or Blanks. 

SEL CASE WHEN TRIM(COLUMNA)='0' THEN NULL ELSE COLUMNA END AS COLUMNA;

I have used TRIM because you have specified i am having the column datatype as CHARACTER. Since the Column length will be the maximum length of the column when we specified in the Create Table.  

CT TABLE A ( A CHAR(10)); 

insert into A('ABC'); 

SEL * FROM A;

The Output will be character ABC followed by 7 Blank Spaces.
 
Thanks & Regards,
Adharssh.


Viewing all articles
Browse latest Browse all 14773

Trending Articles