Concat and case when statement

Analytics
Enthusiast

Concat and case when statement

I need to concatenate 3 fields but the last one may contain "NA" as a value and I do not want that concatenated when found, but rather just left out. I tried this line of code but not working (error says cannot find DB). Any suggestions?

C.GRP_NBR||C.SUBGRP_NBR||C.P_NBR ( CASE WHEN C.P_NBR = 'NA' THEN ' ' ELSE C.P_NBR END) AS ABC_GROUP




Thanks.

2 REPLIES
Enthusiast

Re: Concat and case when statement

I should add that the values can be all numeric or all alpha,  or alpha-numeric and can have leading zeros.

Teradata Employee

Re: Concat and case when statement

The extra "C.P_NBR" in front of the CASE looks like a function reference to the parser. Just remove that.

C.GRP_NBR||C.SUBGRP_NBR||(CASE WHEN C.P_NBR = 'NA' THEN ' ' ELSE C.P_NBR END) AS ABC_GROUP