jeniferfleurant

family member

Oct 19th, 2018
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.99 KB | None | 0 0
  1. USE caris_db;
  2. SET @start_date= '2018-07-01';
  3. SET @end_date='2018-09-30';
  4. select concat(lookup_hospital.city_code,'/',lookup_hospital.hospital_code) as hospital_code,  sum(f_under_1) as f_under_1, sum(f_1_4) as f_1_4, sum(f_5_9) as f_5_9, sum(f_10_14) as f_10_14, sum(f_15_17) as f_15_17, sum(f_18_25) as f_18_25, sum(f_25) as f_25,
  5. sum(m_under_1) as m_under_1, sum(m_1_4) as m_1_4, sum(m_5_9) as m_5_9, sum(m_10_14) as m_10_14, sum(m_15_17) as m_15_17, sum(m_18_25) as m_18_25, sum(m_25) as m_25
  6. from tracking_familymember
  7. left join (select distinct club_patient.id_patient, id_hospital from club_patient
  8. left join club on club_patient.id_club = club.id
  9. left join club_session on club_session.id_club=club_patient.id_club
  10. left join session on session.id_patient = club_patient.id_patient
  11. where is_present = 1 and date between @start_date and @end_date
  12. )a
  13.  on a.id_patient = tracking_familymember.id_patient
  14.  
  15. left join lookup_hospital on lookup_hospital.id = a.id_hospital
  16.  
  17. group by a.id_hospital
Advertisement
Add Comment
Please, Sign In to add comment