select left(patient_code,8) as site, patient_code, dpa, ddr from tracking_pregnancy left join patient on patient.id=id_patient_mother where (dpa>now() or ddr > '2017-01-27') and patient_code is not null group by patient_code