我正在尝试为已经派生的列“Sub1”设置默认文本值这可能吗?我已经使用值0为要派生的列创建了占位符。如果它很重要,我正在Teradata中工作.....谢谢!
select c_clm
,dt.Claimant_Name
,dt.i_ssn
,0 as "Time_Period"
,0 as "Unit_ID",
/*,idv.C_PDT AS "Product"
,er.C_FRM_POL AS "Group Product",*/
(case
when idv.c_pdt is null then 'GLTC'
else idv.c_pdt
end) as "Product_ID"
,c_ams_clm as "DBS_UserID"
,upc_indiv_org_id as "DBS_EEID"
,0 as "Categ"
,0 as Categ_sort
,0 as "Sub1"
,0 as "Sub1_Sort"
,0 as "Sub2"
,0 as "Sub2_Sort"
,0 as "MTD_Num"
,0 as "MTD_Denom"
,dt.i_pol as "Policy_Number"
,COALESCE (erpol.n_pol,idv.n_pol, ks.n_pol)
答案 0 :(得分:12)
您是否尝试这样做:
select '0' as Sub1
您可以直接指定文本值,方法与数字相同。
或者,您是否尝试在SELECT中为NULL时为列分配值。为此,请使用COALESCE:
select coalesce(Sub1, '0') as Sub1
答案 1 :(得分:3)
如果您询问如何使用字符串常量来填充列,只需输入单引号并为其命名即可。通常最好指定所需的列类型。例如:
select 'Text String' (VARCHAR(255)) as sub1
请注意,如果您使用双引号,Teradata会认为您指的是该名称的列(因此您收到的错误消息。