Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set @start_date = '2018-01-01';
- set @end_date = '2018-03-31';
- #SCRIPT FOR MOTHERS WHO HAVE A SESSION BETWEEN END_DATE AND START_DATE
- 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,
- 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
- left join club_session cs on ss.id_club_session = cs.id
- left join club cb on cb.id=cs.id_club
- left join patient pt on ss.id_patient = pt.id
- left join tracking_motherbasicinfo tmb on tmb.id_patient = ss.id_patient
- left join lookup_club_type lt on lt.id = cb.club_type
- left join lookup_hospital lh on cb.id_hospital = lh.id
- where tmb.is_dead != 1 and cb.club_type = 1 and ss.id_patient and pt.id AND ss.is_present
- #THE PATIENT MUST HAVE A SESSION DATE BETWEEN @START_DATE AND @END_DATE
- AND (cs.date between @start_date and @end_date )
- group by pt.id
Add Comment
Please, Sign In to add comment