SELECT 
visitdiag.diagcode,
count(distinct visit.pcucode,visit.pid) as 'คน' ,
count(visitdiag.diagcode) as 'ครั้ง'
from visit 
left join visitdiag on visit.visitno = visitdiag.visitno and visit.pcucode = visitdiag.pcucode   
left join cdisease on visitdiag.diagcode = cdisease.diseasenamethai 
where visitdiag.diagcode LIKE 'A%'
and visit.visitdate between  '2015-05-01' and '2015-05-30'
group by cdisease.diseasecode;