Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USE caris_db;
- SET
- @start_date = "2019-01-01";
- SET
- @end_date = "2019-03-31";
- SET
- @start_date_last = "2018-10-01";
- SET
- @end_date_last = "2018-12-31";
- select patient_code, if(q1 is not null,'yes','no') as q1, if(q2 is not null,'yes','no') as q2 from((
- (select id_patient from tracking_followup where date between @start_date_last and @end_date_last)
- union
- (select id_patient from tracking_followup where date between @start_date and @end_date)
- )unio
- left join
- (select distinct id_patient as q2 from tracking_followup where date between @start_date and @end_date)x
- on unio.id_patient=q2
- left join
- (select distinct id_patient as q1 from tracking_followup where date between @start_date_last and @end_date_last)y
- on unio.id_patient=q1
- left join patient on patient.id=unio.id_patient
- )
Advertisement
Add Comment
Please, Sign In to add comment