select 
visitdate
,sum(case when (substr(visitdate,1,10)<>substr(dateupdate,1,10) )
then 1 else 0 end) as nononestopservice
,sum(case when (substr(visitdate,1,10)= substr(dateupdate,1,10) )
then 1 else 0 end) as onestopservice
,COUNT(pid) as 'ทั้งหมด'
,sum(case when (substr(visitdate,1,10)= substr(dateupdate,1,10) )
then 1 else 0 end)*100/(sum(case when (substr(visitdate,1,10)<>substr(dateupdate,1,10) )
then 1 else 0 end)+sum(case when (substr(visitdate,1,10)= substr(dateupdate,1,10) )
then 1 else 0 end)) as 'ผลงานร้อยละ'
from visit
where visitdate BETWEEN '2015-10-01' AND '2015-10-31' 
group by visitdate
ORDER BY visitdate;