select o.vstdate,count(o.vn) 'Total',sum(c.complete='Y') 'Complete'
,count(o.vn)-sum(c.complete='Y') 'CC'
,sum(o.an is not null) 'Admit'
from ovst o
left join vn_opd_complete c on o.vn=c.vn
where o.vstdate between '2014-1-1' and '2014-1-31'
group by o.vstdate