oop นำข้อมูลมาจาก ovstdiag ครับ
คำสั่งคล้ายๆ แบบนี้ครับ
select vst.hn,vdx.vn,vdx.vstdate as datedx,vdx.icd10 as diag,sp.nhso_code,vdx.diagtype as dxtype,
vst.spclty as clinic,doctor.licenseno as drdx,p.cardno
from ovstdiag vdx
left outer join ovst vst on vst.vn=vdx.vn
left outer join doctor on doctor.code=vst.doctor
left outer join ptcardno p on p.hn = vst.hn and p.cardtype = "01"
left outer join spclty sp on sp.spclty = vst.spclty
where substring(vdx.icd10,1,1) in ("0","1","2","3","4","5","6","7","8","9")
and vdx.vn in (select vn from ovst where vstdate between "2009-05-01" and "2009-05-30" )