Advertisement
jeniferfleurant

count_infant_club

Nov 10th, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.53 KB | None | 0 0
  1. select concat(lookup_hospital.city_code, '/', lookup_hospital.hospital_code) as hospital_code, club.name, lookup_club_type.name, count(*) as patient_count from tracking_infant
  2.  
  3. left join club_patient on club_patient.id_patient = tracking_infant.id_patient
  4. left join club on club.id = club_patient.id_club
  5. left join lookup_hospital on lookup_hospital.id = club.id_hospital
  6. left join lookup_club_type on club.club_type = lookup_club_type.id
  7. where tracking_infant.id_patient in (select id_patient from club_patient)
  8. group by club.id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement