thecassion

mother_who_has_participated_in_a_club_for_btwn_jan_march_31

Feb 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.95 KB | None | 0 0
  1. set @start_date = '2018-01-01';
  2. set @end_date = '2018-03-31';
  3.  
  4. #SCRIPT FOR MOTHERS WHO HAVE A SESSION BETWEEN END_DATE AND START_DATE
  5. select ss.id_patient, tmb.last_name, tmb.first_name,tmb.dob, timestampdiff(YEAR, tmb.dob,NOW()) as age,tmb.address, tmb.telephone,tmb.telephone2,
  6. patient_code as STCODE,cb.name as club_name, lt.name as club_type, cb.id_hospital, lh.name as hospital_name from session as ss
  7. left join club_session cs on ss.id_club_session = cs.id
  8. left join club cb on cb.id=cs.id_club
  9. left join patient pt on ss.id_patient = pt.id
  10. left join tracking_motherbasicinfo tmb on tmb.id_patient = ss.id_patient
  11. left join lookup_club_type lt on lt.id = cb.club_type
  12. left join lookup_hospital lh on cb.id_hospital = lh.id
  13. where tmb.is_dead != 1 and cb.club_type = 1 and ss.id_patient and pt.id AND ss.is_present
  14. #THE PATIENT MUST HAVE A SESSION DATE BETWEEN @START_DATE AND @END_DATE
  15. AND (cs.date between @start_date and @end_date )
  16. group by pt.id
Add Comment
Please, Sign In to add comment