jeniferfleurant

enfant positif (scolarisation)

Oct 18th, 2017
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.74 KB | None | 0 0
  1. set @start_date = '2017-09-01';
  2. set @end_date = now();
  3. select count(*) as total,
  4. if(id_hospital=0, concat(city_code,'/',hospital_code),(select concat(city_code,'/',hospital_code) from lookup_hospital where lookup_hospital.id=id_hospital)) as hospital
  5. from tracking_infant left join patient on patient.id=tracking_infant.id_patient
  6. where timestampdiff(year,dob,@start_date)>=6 and timestampdiff(year,dob,@end_date)<=18
  7. and
  8. id_patient in
  9. (select id_patient from (select id_patient from tracking_followup
  10. union
  11. select id_patient from club_patient
  12. union
  13. select id_patient from tracking_regime
  14. )df
  15. )
  16. and linked_to_id_patient=0
  17. and (is_dead=0 or death_date>@start_date)
  18. and (is_abandoned=0 or abandoned_date>@start_date)
  19. group by hospital
Advertisement
Add Comment
Please, Sign In to add comment