All Forums Database
Vishnujp 4 posts Joined 06/16
09 Jun 2016
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

~~Vishnu
Johannes Vink 28 posts Joined 08/14
09 Jun 2016

Set the alias between double quotes: AS "CURRENT_DATE"

Vishnujp 4 posts Joined 06/16
13 Jun 2016

tried that... dint work

~~Vishnu

M.Saeed Khurram 544 posts Joined 09/12
13 Jun 2016

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

sk8s3i 35 posts Joined 06/13
13 Jun 2016

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
;

-Thanks Shardul

Vishnujp 4 posts Joined 06/16
13 Jun 2016

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)

~~Vishnu

Vishnujp 4 posts Joined 06/16
13 Jun 2016

The output looks like this
Current_date
16

~~Vishnu

You must sign in to leave a comment.