Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- p1.patient_code AS primary_patient_code,
- a.*,
- lh.name AS current_hospital_name,
- CONCAT(lh.city_code, '/', lh.hospital_code) AS current_site_code
- FROM
- (SELECT
- linked_to_id_patient AS id_patient,
- GROUP_CONCAT(patient_code
- SEPARATOR '&&') AS linked_code,
- COUNT(linked_to_id_patient) AS numb
- FROM
- patient p
- WHERE
- linked_to_id_patient != 0
- GROUP BY linked_to_id_patient) a
- left join patient p1 on p1.id=a.id_patient
- left join tracking_motherbasicinfo tmi on tmi.id_patient = p.a.id_patient
- left join tracking_infant ti on ti.id_patient=a.id_patient
- left join lookup_hospital lh on lh.id=ti.id_hospital
- where tmi.id is null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement