jeniferfleurant

HIV_STAT part 2

Apr 13th, 2018
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.50 KB | None | 0 0
  1. USE caris_db;
  2. SET @start_date='2017-10-01';
  3. SET @end_date='2018-03-31';
  4.  
  5. select left(patient_code,8) as hospital, sum(pcr_result=2) as neg, sum(pcr_result!=1 and pcr_result!=2) as unknown_status from(
  6. select * from testing_specimen ts
  7. where date_blood_taken between @start_date and @end_date
  8. and date_blood_taken=(select min(date_blood_taken) from testing_specimen ts1 where ts.id_patient=ts1.id_patient)
  9. group by id_patient
  10.  )x
  11.  left join patient on patient.id=id_patient
  12.  group by left(patient_code,8)
Advertisement
Add Comment
Please, Sign In to add comment