งง กับ 2 คำสั่งนี้ครับ
1.หาจำนวน Visit OPD ได้ 135220select count(v.vn)
from ovst o
left outer join vn_stat v on v.vn=o.vn
where o.vstdate between "2013-10-01" and "2014-09-30"
2.หาจำนวน Visit OPD แยกตามแผนกได้ 135219select v.spclty,s.name,count(v.vn) as c_vn
from ovst o
left outer join vn_stat v on v.vn=o.vn
left outer join spclty s on s.spclty=v.spclty
where v.vstdate between "2013-10-01" and "2014-09-30"
group by v.spclty
order by s.name asc