LEFT JOIN( SELECT fund.employee_id, fund.id FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON social.employee_id = fund.employee_id
LEFT JOIN( SELECT other.employee_id, other.id FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON social.employee_id = other.employee_id
WHERE
social.delete_type = 0
<iftest="employeeIds != null and employeeIds.size()>0">
LEFT JOIN( SELECT social.employee_id, social.social_end_time FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON t.employee_id = social.employee_id
LEFT JOIN( SELECT fund.employee_id, fund.fund_end_time FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON t.employee_id = fund.employee_id
LEFT JOIN( SELECT other.employee_id, other.other_end_time FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON t.employee_id = other.employee_id
WHERE t.delete_type = 0
AND t.run_status = '3'
AND (
(social.social_end_time is not null and social.social_end_time <![CDATA[ <> ]]> '' and social.social_end_time <![CDATA[ > ]]> #{today})
OR
(fund.fund_end_time is not null and fund.fund_end_time <![CDATA[ <> ]]> '' and fund.fund_end_time <![CDATA[ > ]]> #{today})
OR
(other.other_end_time is not null and other.other_end_time <![CDATA[ <> ]]> '' and other.other_end_time <![CDATA[ > ]]> #{today})
LEFT JOIN( SELECT social.employee_id, social.social_end_time FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON t.employee_id = social.employee_id
LEFT JOIN( SELECT fund.employee_id, fund.fund_end_time FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON t.employee_id = fund.employee_id
LEFT JOIN( SELECT other.employee_id, other.other_end_time FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON t.employee_id = other.employee_id
WHERE t.delete_type = 0
AND t.run_status = '2'
AND social.social_end_time is not null and social.social_end_time <![CDATA[ <> ]]> '' and social.social_end_time <![CDATA[ <= ]]> #{today}
AND fund.fund_end_time is not null and fund.fund_end_time <![CDATA[ <> ]]> '' and fund.fund_end_time <![CDATA[ <= ]]> #{today}
AND other.other_end_time is not null and other.other_end_time <![CDATA[ <> ]]> '' and other.other_end_time <![CDATA[ <= ]]> #{today}