can I get help...im really newbie at SQL, and this code is a legacy from my former asscociate.
Im using hive query and I got an issue at line 53:65 missing EOF
here's the code:
SELECT
'24-08-20' AS AS_OF_DATE,
'KRK' AS Flag,
B.COD_LOB AS LOB_CODE,
A.COD_CUST AS CIF_KEY,
A.NAM_CUST_SHRT AS CUST_NAME,
CAST (A.COD_ACCT_NO AS CHAR(12)) as ACCOUNT_NUMBER,
' ' AS CONTRACT_REF_NO,
-------A.COD_CCY AS CCY,
CASE A.COD_CCY WHEN 36 THEN 'AUD' WHEN 124 THEN 'CAD' WHEN 344 THEN 'HKD' WHEN 356 THEN 'INR' WHEN 360 THEN 'IDR'
WHEN 392 THEN 'JPY' WHEN 458 THEN 'MYR' WHEN 554 THEN 'NZD' WHEN 578 THEN 'NOK' WHEN 702 THEN 'SGD' WHEN 752 THEN 'SEK'
WHEN 756 THEN 'CHF' WHEN 764 THEN 'THB' WHEN 826 THEN 'GBP' WHEN 978 THEN 'EUR' WHEN 840 THEN 'USD' ELSE 'OTHER' END CCY,
cast (A.COD_PROD as char(10)) AS PRODUCT_CODE_NCBS,
cast (A.COD_PROD as char(10)) AS PROD_ICBS,
D.NAM_PRODUCT as PRODUCT_DESC,
L.RAT_INT AS CUR_NET_RATE,
INT_VAR.RAT_VARIANCE AS RAT_VARIANCE,
'NULL' AS INDEX_RATE,
(CASE WHEN(INT_VAR.RAT_VARIANCE) IS NULL THEN L.RAT_INT ELSE (L.RAT_INT + INT_VAR.RAT_VARIANCE)END) AS NET_INTEREST,
rtrim(convert (DAT_ACCT_OPEN,111)) AS ACCOUNT_OPEN_DATE,
rtrim(convert(LINE_START_DATE,111)) AS ROLLOVER_DATE,
rtrim(convert(LINE_EXPIRY_DATE,111))AS MATURITY_DATE,
CAST (COD_ACCT_STAT AS CHAR(3)) AS ACCOUNT_STATUS,
rtrim(convert(LINE_EXPIRY_DATE,111))AS ACCOUNT_CLOSE_DATE,
B.COD_AO_BUSINESS AS AO_BUSINESS,
A.COD_CC_BRN AS BRANCH_CD,
C.cod_brn_type AS BRANCH_REGIONAL,
C.nam_branch AS BRANCH_DESCRIPTION,
(A.BAL_BOOK*-1) AS BALANCE_ORI,
case when i.nam_ccy_short = 'IDR' and H.COD_CRR_TO>20 then (a.BAL_BOOK*-1)-tunggak.BUNGA_TUNGGAK else
case when i.nam_ccy_short <> 'IDR' and H.COD_CRR_TO>20 then (a.BAL_BOOK*j.revrate*-1)-tunggak.BUNGA_TUNGGAK else
case when i.nam_ccy_short = 'IDR' and H.COD_CRR_TO<=20 then (a.BAL_BOOK*-1) else (a.BAL_BOOK*j.revrate*-1) end end end as BALANCE_IDR,
A.COD_LINE_NO AS CREDIT_LINE_ID,
G.RECORD_STAT AS LINE_STATUS,
M.dat_limit_start AS DATE_DISB,
G.LIMIT_AMOUNT AS LIMIT_PLAFON_ORI,
case when i.nam_ccy_short = 'IDR' then (G.LIMIT_AMOUNT) else (G.LIMIT_AMOUNT*j.revrate) end as LIMIT_PLAFON_IDR,
H.COD_CRR_TO AS COLL,
'FCR-KRK-NCBS' AS SOURCE_DATA
-----------------------------------------
FROM (Select COD_CUST, NAM_CUST_SHRT,COD_ACCT_NO,COD_CCY,COD_PROD,COD_ACCT_STAT,COD_CC_BRN,BAL_BOOK,COD_LINE_NO,DAT_ACCT_OPEN from newmisplus2.BD_MIS_CH_ACCT_MAST where date_pr='20200824') A INNER JOIN (SELECT COD_PROD,COD_CCY,FLG_USE_TIERED_RATES_FOR_OD from newmisplus2.BD_CH_PROD_MAST WHERE COD_TYP_PROD='A' AND date_pr='20200824' ) X ON A.COD_PROD=X.COD_PROD AND A.COD_CCY=X.COD_CCY
LEFT JOIN (SELECT RAT_INT,COD_PROD from newmisplus2.BD_CH_INT_TAB WHERE COD_INT_TYPE='DR' AND date_pr='20200824') OD_DR ON A.COD_PROD=OD_DR.COD_PROD
LEFT JOIN (SELECT RAT_INT,COD_PROD from newmisplus2.BD_CH_INT_TAB WHERE COD_INT_TYPE='OL' AND date_pr='20200824') OD_OL ON A.COD_PROD=OD_OL.COD_PROD
LEFT JOIN (SELECT RAT_VARIANCE,COD_ACCT_NO from newmisplus2.BD_MIS_CH_ACCT_CUR_VARIANCE WHERE COD_INT_TYPE = 'DR' AND date_pr='20200824') INT_VAR
ON A.COD_ACCT_NO=INT_VAR.COD_ACCT_NO
LEFT JOIN
(SELECT A.COD_LIMIT_NO,AMT_LIMIT,RAT_INT_EFFECTIVE,A.COD_ACCT_NO from newmisplus2.BD_CH_OD_LIMIT where date_pr='20200824') A
INNER JOIN (SELECT COD_ACCT_NO,MAX(COD_LIMIT_NO) AS COD_LIMIT_NO from newmisplus2.BD_CH_OD_LIMIT where date_pr='20200824' GROUP BY COD_ACCT_NO) B
ON A.COD_ACCT_NO=B.COD_ACCT_NO AND A.COD_LIMIT_NO=B.COD_LIMIT_NO OD_INT_EFF ON A.COD_ACCT_NO=OD_INT_EFF.COD_ACCT_NO
-----------------------------------------
is there any suggestion to fix the script? thanks before
Maybe there are more issues. What I have found:
A
subquery has the same nameA
as the first subquery after FROM, also it has no ON condition