Archives of the TeradataForum
Message Posted: Wed, 14 Jul 2004 @ 17:06:45 GMT
Subj: | | Re: Changing a column name while concatinating |
|
From: | | Anomy Anom |
<-- Anonymously Posted: Wednesday, July 14, 2004 11:48 -->
I had to do something similar to parse complex strings pre-UDF. The only solution I came up with is to alias the case expressions as columns in
a derived table:
SELECT FinalCol
FROM (
SELECT CASE WHEN THEN ELSE '' END NewCol1
, CASE WHEN THEN ELSE ''
END || NewCol1 NewCol2
, CASE WHEN THEN ELSE ''
END || NewCol2 NewCol3
...
, NewColN || 'bar' FinalCol
)
;
or
SELECT NewCol1 || NewCol2 || NewCol3 || .... || NewColN || 'bar'
FinalCol
FROM (
SELECT CASE WHEN THEN ELSE '' END NewCol1
, CASE WHEN THEN ELSE ''
END NewCol2
, CASE WHEN THEN ELSE ''
END NewCol3
...
, 'bar' FinalCol
)
;
|