SELECT CC.CUSTOMER_ID AS customerId
 FROM CAMPAIGN_CUSTOMER CC
    LEFT JOIN CCMS_FULL.RECEIVE_CUST_LOG CL ON CC.CUSTOMER_ID = CL.CUSTOMER_ID
 WHERE CC.CAMPAIGN_ID = :campaignId
  AND CC.COMPANY_SITE_ID = :companySiteId
  AND CC.IN_CAMPAIGN_STATUS = 1
  AND CL.CUSTOMER_ID IS NULL
  AND CL.END_TIME IS NULL
  AND EXISTS(SELECT 1
        FROM CCMS_FULL.CAMPAIGN_COMPLETE_CODE CCC
        WHERE CC.STATUS = CCC.COMPLETE_VALUE
          AND STATUS = 1
          AND IS_FINISH = 0
          AND COMPLETE_TYPE = 1
          AND COMPANY_SITE_ID = :companySiteId)
  AND CC.RECALL_COUNT < C.MAX_RECALL
  AND SYSDATE – MAX(CC.CALL_TIME) >= C.RECALL_DURATION
  AND C.STATUS = 1
  AND C.CALL_ALLOWED = 1
  AND C.IPCC_STATUS = 'active'
