2

我正在尝试为已经派生的列“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) 
4

2 回答 2

26

您是否尝试这样做:

select '0' as Sub1

您可以直接分配文本值,方法与数字相同。

或者,您是否尝试在 SELECT 中为 NULL 时为列分配值。为此,请使用 COALESCE:

select coalesce(Sub1, '0') as Sub1
于 2012-08-30T19:32:52.277 回答
4

如果您询问如何使用字符串常量来填充列,只需将其放在单引号中并为其命名。通常最好指定所需的列类型。例如:

select 'Text String' (VARCHAR(255)) as sub1

请注意,如果您使用双引号,Teradata 会认为您指的是该名称的列(因此您收到的错误消息。

于 2012-08-30T19:45:51.967 回答