Converting a field value to a column name

Database
New Member

Converting a field value to a column name

Hi all,

I am wondering whether it is possible to covert a field value into a column heading. Below is an example of what I am looking for:

Create Volatile Table V_Start as (Select Extract(Year from Current_Date) as Strt_Yr) with data on commit preserve rows;

SELECT
'Two years ago' AS DT.Strt_Yr - 2
, 'One year ago' AS DT.Strt_Yr -1
, 'This year' AS DT.Strt_Yr
FROM
V_Start DT
;

The reason that I don't want to hard code the headings is that they need to automatically adjust when the year rolls over.

I have tried:

.....AS Cast(DT.Strt_Yr as Char(4))
.....AS 'Year'||Cast(DT.Strt_Yr as Char(4))

but continue to get errors.

So, is it possible ?
1 REPLY
Enthusiast

Re: Converting a field value to a column name

See http://www.teradata.com/teradataforum/Topic17517-5-1.aspx#bm17547