Current date as column name in select query

Database

Current date as column name in select query

Hi All,

I need to set alias to a column name as current_date in the format (DDMMMYYYY) in a select query (Teradata version 14).

Eg: Select case when ... then

                         else ...    

                   end as current_date

from T1

6 REPLIES
Enthusiast

Re: Current date as column name in select query

Set the alias between double quotes: AS "CURRENT_DATE"

Re: Current date as column name in select query

tried that... dint work
Enthusiast

Re: Current date as column name in select query

Hi,

This is standard in teradata to eclose key words in double qoutes if you want to use them as Alias. I have tested and it works fine on SQLA.

Which query tool are you using?

Br,

Khurram

Khurram
Enthusiast

Re: Current date as column name in select query

Yes, it works fine. You will just need to enclose the Alias in double quotes:

SELECT
CASE WHEN ... THEN 1
ELSE 0
END AS "CURRENT_DATE"
FROM DB_Name.TABLE_NAME
;

Re: Current date as column name in select query

Hi ,

I tried the same

max((case order_dt when cast ((cast(current_date -9 as format 'ddmmmyyyy')) as char(9)) then "seq" else null end)) as "current_date",

and this is the output

I am using Teradata SQL Assistant (V 14.1)

Re: Current date as column name in select query

The output looks like this
Current_date
16