第一次的SQL,先搜索到了满足大于当前日期的数据再进行只有一条的数据筛选
SELECT contract_no \ FROM stellr_renew_opportunity WHERE country_code ='${country_code}' and renew_status ='ACTION_REQUIRED' and service_end_date >=CURRENT_DATE() and reseller_no !='${test_reseller}' AND \ is_latest =1 AND \ delete_id is NULL and delete_datetime is NULL group BY contract_no HAVING COUNT(contract_no)=1 \ LIMIT 10
第二次的SQL,先搜索只有一条记录的数据,在进行只有一条的数据筛选
select contract_no from stellr_renew_opportunity where service_end_date >=CURRENT_DATE() and reseller_no !='${test_reseller}' AND is_latest =1 AND delete_id is NULL and delete_datetime is NULL AND contract_no in (SELECT contract_no FROM stellr_renew_opportunity WHERE country_code ='${country_code}' and renew_status ='ACTION_REQUIRED' group BY contract_no HAVING COUNT(*)=1 )