优化下这个代码 select sum(auth_amt) sum_auth_amt from auth_cont auth where auth_sts = '1' and exists (select 1 from RPT_DUE_LOAN_ACC_M loan where loan.cif_no = auth.cif_no AND 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 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 16:37:34 浏览: 122
答案:SELECT SUM(AUTH_AMT) SUM_AUTH_AMT FROM AUTH_CONT AUTH WHERE AUTH_STS = 1 AND EXISTS(SELECT 1 FROM RPT_DUE_LOAN_ACC_M LOAN WHERE LOAN.CIF_NO = AUTH.CIF_NO AND 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) 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));
阅读全文