SELECT properties.id, properties.parcel_id, properties.state, properties.county, properties.assessed_value, properties.in_same_zip, properties.in_same_state
FROM properties left join (SELECT GREATEST(tax_history.date_paid_2nd_half_2,
COALESCE(tax_history.date_paid_2nd_half_1, 0),
COALESCE(tax_history.date_paid_1st_half_2, 0),
COALESCE(tax_history.date_paid_1st_half_1, 0)) as latest_date, property_id from tax_history) as tax_history ON tax_history.property_id = properties.id
This query is working but it is very slow, I have thousands of records