select year(a.nextdate)+543 year,month(a.nextdate) month
,count(a.vn) 'case'
,count(if(a.patient_visit='Y',a.vn,null)) 'confirm'
,count(if(a.patient_visit<>'Y' or a.patient_visit is null,a.vn,null)) 'no'
from oapp a
where a.nextdate between '2012-10-1' and '2013-9-30'
group by year,month