首页 > 代码库 > Oracle 统计最近6个月满足条件的客户

Oracle 统计最近6个月满足条件的客户

 

SELECT
    c.*
    FROM
    AVERAGE_DAILY_OVERDRAFT c,CUSTOMER_ACCOUNT_INFORMATION b
    WHERE
    TO_DATE (c.YEAR||c.MONTH, ‘YYYYMM‘) <![CDATA[ <= ]]>SYSDATE
    AND TO_DATE (c.YEAR||c.MONTH, ‘YYYYMM‘) > ADD_MONTHS (SYSDATE, - 6)
    AND not EXISTS(
    select * from AVERAGE_DAILY_OVERDRAFT a where a.ACCOUNT_NUMBER = c.ACCOUNT_NUMBER
    and a.ALL_DUE_STATUS = 0
     )
   AND c.ACCOUNT_NUMBER=b.ACCOUNT_NUMBER
   and c.TOTAL_AMOUNT_OVERDRAFT/b.CREDIT_AMOUNT >=0.5

Oracle 统计最近6个月满足条件的客户