GROUP BY EMP_IDCARD_NO,BUY_STANDARD, INSURANCE_TYPE) cig
ON t.EMP_IDCARD_NO = cig.EMP_IDCARD_NO AND t.POLICY_END = cig.POLICY_END AND t.BUY_STANDARD = cig.BUY_STANDARD and
t.INSURANCE_TYPE = cig.INSURANCE_TYPE
join t_insurance_company tic on t.INSURANCE_COMPANY = tic.ID
join t_insurance_type p on t.INSURANCE_TYPE=p.ID
left join t_insurance_replace tir on t.ID = tir.INSURANCE_ID
LEFT JOIN (select l.* from t_insurance_replace l left join t_business_insurance tbi on l.TO_INSURANCE_ID = tbi.ID where tbi.invalid_Flag='0' and STATUS!=4 ) re ON t.id= re.INSURANCE_ID