Teradata 3706,预计在DISTINCT和LEFT关键字之间

时间:2016-04-03 19:53:15

标签: sql select join sql-update teradata

我在这里尝试使用JOIN和SELECT的UPDATE查询,但我面临3706错误。

这是错误行 -

Teradat error

UPDATE A0619IL3549_D_RPT.RPT_IS_ELIGIBILITY A2
FROM
(SELECT A.REP_CD, A.GEO_CD,A.MONTH_ID, B.IC_PRD AS IC_PAYOUT_FLAG,
COALESCE(CASE 
WHEN UPPER(B.IC_PRD) = 'SEMESTERLY' THEN A.CURR_SEMESTER_FLAG
WHEN UPPER(B.IC_PRD) = 'QUARTERLY' THEN A. CURR_QUARTER_FLAG
ELSE '0'
END,'0') IC_PAYOUT_FLAG
FROM 
A0619IL3549_D_RPT.RPT_IS_ELIGIBILITY A,
(
SELECT DISTINCT LEFT(B. REP_CD, POSITION('-' IN B.REP_CD)-1) AS REP_CD,C.GEO_CD,IC_PRD FROM 
A0619IL3549_D00_IC_MAIN.ICDM_GEO_REP_PROD A, A0619IL3549_D00_IC_MAIN.ICDM_DIM_REP B,
A0619IL3549_D00_IC_MAIN.ICDM_DIM_GEO_HIER C WHERE A.REP_SK=B.REP_SK AND A.GEO_SK=C.GEO_SK AND A.RUN_ID = (SELECT MAX(RUN_ID) FROM A0619IL3549_D00_IC_MAIN.ICDM_GEO_REP_PROD) ) B WHERE A.REP_CD = B.REP_CD AND A.GEO_CD = B.GEO_CD)A1 SET A2.IC_PAYOUT_FALG = A1.IC_PAYOUT_FLAG WHERE A1.REP_CD = A2.REP_CD AND A1.MONTH_ID = A2.MONTH_ID AND A.GEO_CD = A2.GEO_CD

1 个答案:

答案 0 :(得分:1)

LEFT在TD15.10之前不是有效的Teradata函数,它是ODBC SQL,它是自动翻译的,但仅适用于SELECT

使用有效的语法:

SUBSTRING(B. REP_CD FROM 1 FOR POSITION('-' IN B.REP_CD)-1)