帮忙分下SQL 语句哪里出错了,谢谢!
本帖最后由 ggxxkkll 于 2013-09-06 16:25:01 编辑 下面是SQL语句:
SELECT
CAST(S_TP2_Customer.CUST_NUMBER as Varchar(15)) as Cust,
S_TP2_Siebel.*,
S_TP2_CompanyInfo.COMPANY_NUMBER,
cast(NULLIF(
otranslate(
case
when position('!' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('@' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('#' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('$' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('%' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('^' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('&' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('*' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('(' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position(')' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('-' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('_' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('+' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('=' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('{' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('[' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('}' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position(']' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('|' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('\' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position(':' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position(';' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('"' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('''' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('<' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position(',' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('>' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('.' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('?' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
when position('/' in S_TP2_CompanyInfo.COMPANY_NUMBER) > 0 then NULL
else S_TP2_CompanyInfo.COMPANY_NUMBER
end, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ', ''
), '')
as varchar(30)) as CRN_Initial,
otranslate(cast(CRN_Initial as varchar(30)), '0', '') as Testa
FROM EDW1TST_StagePerm.S_TP2_Customer S_TP2_Customer
LEFT OUTER JOIN EDW1TST_StagePerm.S_TP2_CompanyInfo S_TP2_CompanyInfo
ON S_TP2_Customer.CUST_NUMBER = S_TP2_CompanyInfo.CUST_NUMBER
AND date (date) between S_TP2_CompanyInfo.Hist_Start_Dt and S_TP2_CompanyInfo.Hist_End_Dt
LEFT OUTER JOIN EDW1TST_StagePerm.S_TP2_Siebel S_TP2_Siebel
ON S_TP2_Customer.CUST_NUMBER = S_TP2_Siebel.CUST_NUMBER
AND date (date) between S_TP2_Siebel.Hist_Start_Dt and S_TP2_Siebel.Hist_End_Dt
--LEFT OUTER JOIN EDW1TST_StageTemp.I_CDI_SBL_Party_Name I_CDI_SBL_Party_Name_C
--ON I_CDI_SBL_Party_Name_C.CRM_ID = S_TP2_Siebel.Siebel_ID
WHERE date (date) between S_TP2_Customer.Hist_Start_Dt and S_TP2_Customer.Hist_End_Dt
AND S_TP2_Customer.INTENDED_USE = 'BUSINESS'
AND S_TP2_Customer.CUST_NUMBER = 5991513

