I'm trying to execute the following code, but it seems that Teradata continues to get hung-up on the put function in my code. I'm using this function because one of the variables exists as numeric in one source and as a char in another source. The error I receive is:  Syntax error: Data Type "cust_key" does not match a Defined Type name. Any ideas? Thanks in advance.
SyntaxEditor Code Snippet
create table db.table_output as (select a.*,b.inst_IN,b.group,b.type,b.date,b.amount, b.inst from db.table1 a left join (select cust_no_1 as cust_key,date,group,type,inst_in,inst,amount from db.table2 where final_in=1 and cust_key is not null union all select cust_no_2 as cust_key,date,group,type,inst_in,inst,amount from db.table2 where final_in=1 and cust_key is not null ) b on put(a.cust_key,15.)=b.ecn_key and datepart(b.date)- datepart(a.date)>0 and datepart(b.date)-datepart(a.date)<=60 and a.cust_key is not null) with data;
put and datepart are not valid sql.
use cast(a.cust_key as char(nn)) to cast it to a character of nn length.
looks like the date logic can change to:
and (b.date - a.date) between 1 and 60
PUT is not a Teradata SQL function. The parser thinks you are trying to specify cust_key as a data type. You can explicitly cast the char to decimal or integer, e.g., ... on cast(a.cust_key as decimal(15,0)=b.ecn_key. (Match it to whatever specific data type the other key is.)