select year, count(id_patient) as under_8_weeks, sum(positive) from (select year(date_blood_taken) as year, id_patient, if(pcr_result=1,1,0) as positive from testing_specimen where which_pcr=1 and timestampdiff(week,date_of_birth,date_blood_taken)<=8 and date_blood_taken between '2015-01-01' and '2017-06-30' group by id_patient )d group by year
Comments