select a.vstdate,o.vsttime,a.vn
,pt.pname,pt.fname,pt.lname
,o.doctor,dr.name doctorname
,v.pdx
from (select vstdate,min(vn) vn
from ovst
where vstdate between '2012-1-1' and '2012-1-31'
group by vstdate) a
left join ovst o on a.vn=o.vn
left join vn_stat v on o.vn=v.vn
left join patient pt on o.hn=pt.hn
left join doctor dr on o.doctor=dr.code
ประมาณนี้มั๊ย