优化下这个代码 select sum(auth_amt) sum_auth_amt from auth_cont auth left join (select * from RPT_DUE_LOAN_ACC_M loan where loan.send_flag = '2' and loan.prd_userdf_type != '3017' and loan.bank_id = 162000 and (loan.cif_no in (select cif_no from RPT_DUE_LOAN_ACC_M a where 1 = 1 AND LOAN.YEAR = '2021' AND LOAN.MONTH = '12' AND LOAN.ACCOUNT_STATUS NOT IN ('0', '2') AND ((LOAN.LOAN_BAL > 0 OR LOAN.IN_INTST > 0 OR LOAN.OUT_INTST > 0 OR LOAN.CMPD_INTST > 0) or substr(LOAN.SETTL_DATE, 0, 6) = '202112') AND LOAN.MANG_BR_NO IN (SELECT BR_NO FROM TBL_ORG_DEPARTMENTS START WITH BR_NO = '162000' CONNECT BY PRIOR BR_NO = UP_ONE) group by cif_no and (loan.cif_no in (select cif_no from RPT_DUE_LOAN_ACC_M a where 1 = 1 AND LOAN.YEAR = '2021' AND LOAN.MONTH = '12' AND LOAN.ACCOUNT_STATUS NOT IN ('0', '2') AND ((LOAN.LOAN_BAL > 0 OR LOAN.IN_INTST > 0 OR LOAN.OUT_INTST > 0 OR LOAN.CMPD_INTST > 0) or substr(LOAN.SETTL_DATE, 0, 6) = '202112') AND LOAN.MANG_BR_NO IN (SELECT BR_NO FROM TBL_ORG_DEPARTMENTS START WITH BR_NO = '162000' CONNECT BY PRIOR BR_NO = UP_ONE) group by cif_no group by cif_no) loan on loan.cif_no = auth.cif_no where auth_sts = '1' AND LOAN.YEAR = '2021' AND LOAN.MONTH = '12' AND LOAN.ACCOUNT_STATUS NOT IN ('0', '2') AND ((LOAN.LOAN_BAL > 0 OR LOAN.IN_INTST > 0 OR LOAN.OUT_INTST > 0 OR LOAN.CMPD_INTST > 0) or substr(LOAN.SETTL_DATE, 0, 6) = '202112') AND LOAN.MANG_BR_NO IN (SELECT BR_NO FROM TBL_ORG_DEPARTMENTS START WITH BR_NO = '162000' CONNECT BY PRIOR BR_NO = UP_ONE)
时间: 2023-03-14 10:41:04 浏览: 134
答:SELECT SUM(AUTH_AMT)SUM_AUTH_AMT FROM AUTH_CONT AUTH LEFT JOIN(SELECT * FROM RPT_DUE_LOAN_ACC_M LOAN WHERE LOAN.SEND_FLAG = 2 AND LOAN.PRD_USERDF_TYPE != 3017 AND LOAN.BANK_ID = 162000 AND(LOAN.CIF_NO IN(SELECT CIF_NO FROM RPT_DUE_LOAN_ACC_M A WHERE LOAN.YEAR = 2021 AND LOAN.MONTH = 12 AND LOAN.ACCOUNT_STATUS NOT IN(0,2)AND((LOAN.LOAN_BAL>0 OR LOAN.IN_INTST>0 OR LOAN.OUT_INTST>0 OR LOAN.CMPD_INTST>0)OR SUBSTR(LOAN.SETTL_DATE,0,6)= 202112)AND LOAN.MANG_BR_NO IN(SELECT BR_NO FROM TBL_ORG_DEPARTMENTS START WITH BR_NO = 162000 CONNECT BY PRIOR BR_NO = UP_ONE)GROUP BY CIF_NO)ON LOAN.CIF_NO = AUTH.CIF_NO WHERE AUTH_STS = 1 AND LOAN.YEAR = 2021 AND LOAN.MONTH = 12 AND LOAN.ACCOUNT_STATUS NOT IN(0,2)AND((LOAN.LOAN_BAL>0 OR LOAN.IN_INTST>0 OR LOAN.OUT_INTST>0 OR LOAN.CMPD_INTST>0)OR SUBSTR(LOAN.SETTL_DATE,0,6)= 202112)AND LOAN.MANG_BR_NO IN(SELECT BR_NO FROM TBL_ORG_DEPARTMENTS START WITH BR_NO = 162000 CONNECT BY PRIOR BR_NO = UP_ONE)GROUP BY CIF_NO)LOAN ON LOAN.CIF_NO = AUTH.CIF_NO WHERE AUTH_STS = 1。
阅读全文