Sql server SQL代码-使用案例对客户进行分类-错误3625,但找不到错误
我试图将客户分为三类:REMIC、REMIR和HC 编号为“682010”、“682020”、“683220”的客户为HC-->其他客户为REMIC或REMIR REMIR=在商业房地产中没有违约风险敞口(04),但在住宅中有违约风险敞口(05) 我已经创建了一个案例公式,但是它一直给我错误3625-我知道我应该正确计算,所以看不到错误Sql server SQL代码-使用案例对客户进行分类-错误3625,但找不到错误,sql-server,Sql Server,我试图将客户分为三类:REMIC、REMIR和HC 编号为“682010”、“682020”、“683220”的客户为HC-->其他客户为REMIC或REMIR REMIR=在商业房地产中没有违约风险敞口(04),但在住宅中有违约风险敞口(05) 我已经创建了一个案例公式,但是它一直给我错误3625-我知道我应该正确计算,所以看不到错误 select CU.CD03001 as "Local Customer ID", case when "Commercial
select
CU.CD03001 as "Local Customer ID",
case
when "Commercial Real Estate EAD" is null then 'O'
else 'X'
end as "Commercial Status",
case
when "Residential Real Estate EAD" is null then 'O'
else 'X'
end as "Residential Status",
case
when CU.CD03008='DK'
and CU.CD03025 not in ('682010','682020','683220')
and "Commercial Status" = 'O'
and "Residential Status" = 'X'
then 'REMIR'
when CU.CD03008='DK'
and CU.CD03025 in ('682010','682020','683220')
then 'HC'
else 'REMIC'
end as "Customer Group",
CU.CD03010 as Business_Partner_Name,
ORG1.CD01007_Cd as BA1,
ORG1.CD01008 as BA2,
BA2_NM.Acctng_unit_com_nm AS "Banking Unit",
case ORG1.CD01008
when '6002092' then ORG1.region_cd
else ORG1.CD01009
end as BA3,
BA3_NM.Acctng_unit_com_nm AS "Branch Region",
SD.Common_Cust_Seg_Lvl3_CD,
SD.Common_Cust_Seg_Lvl3_Desc,
CU.CD09075 as Rating,
COALESCE(sum(Case when CR.CD09076_Collateral_Category_Cd = '04' then CR.CD09014_Exposure_at_Default else 0 END),0) as "Commercial Real Estate EAD",
COALESCE(sum(Case when CR.CD09076_Collateral_Category_Cd = '05' then CR.CD09014_Exposure_at_Default else 0 END),0) as "Residential Real Estate EAD"
FROM PROD_INT_SL_DX_VIEWS.organization_dim ORG1
LEFT JOIN ( SELECT
Customer_Id,
CD03001,
CD03008,
CD03010,
CD03025,
CD03026,
CD03029,
CD09075
FROM PROD_INT_SL_DX_VIEWS.customer_dim
where CD03025='L'
and CD03008 = 'DK'
group by 1,2,3,4,5,6,7,8 ) CU
ON ORG1.CD01001=CU.CD03026
LEFT JOIN
(SELECT DISTINCT CD01001, Acctng_unit_com_nm
FROM PROD_INT_SL_DX_VIEWS.ORGANIZATION_HIER) AS BA2_NM
ON TRIM(ORG1.CD01008) = TRIM(BA2_NM.CD01001)
LEFT JOIN
(SELECT DISTINCT CD01001, Acctng_unit_com_nm
FROM PROD_INT_SL_DX_VIEWS.ORGANIZATION_HIER) AS BA3_NM
ON TRIM(BA3) = TRIM(BA3_NM.CD01001)
LEFT JOIN PROD_INT_SL_DX_VIEWS.customer_segment_dim SD
ON CU.CD03029=SD.CD03029
LEFT JOIN PROD_INT_SL_CPS_VIEWS.Financial_Fact FF
on CU.Customer_Id=FF.Customer_Id
LEFT JOIN PROD_INT_SL_CPS_VIEWS.PRODUCT_DIM PD
ON FF.Product_Party_Type_Id=PD.Product_Party_Type_Id
LEFT JOIN PROD_INT_SL_CPS_VIEWS.CREDIT_RISK_FACT CR
ON FF.Agreement_Id=CR.Agreement_Id
where BA1='6002000'
and BA2 in ('6002091')
and SD.Common_Cust_Seg_Lvl3_CD in ('C30100','C20100','C10100','RB_C50100','C60100')
and FF.Year_Month_Id in ('201409') and FF.period_type in ('AVGP','AVGY')
and FF.CD12001_Currency_Unit='EUR'
and PD.Language_Code='eng'
group by 1,2,3,4,5,6,7,8,9,10,11,12,13
order by 1
什么是
“住宅房地产EAD”
列名?是的是我创建的一个列,用于汇总住宅房地产的默认支出(EAD),对商业房地产也是如此。SQL server的哪个版本?你试过用方括号替换引号吗[Residential Real Estate EAD]
是的,我有Teradata SQL assistant,我确信问题在一开始就存在于这三个案例中,因为如果我将它们取出,查询运行正常-但我需要它们对客户进行细分。