select distinct pt.hn,pt.cid,ov.vstdate,concat(pt.pname,pt.fname,' ',pt.lname)as tname,pt.birthday,ov.age_y,
pt.sex,os.bw,os.height,concat(os.bpd,"/",os.bps)as mmhg,pt.nationality,nn.name,oc.occupation,
oc.name,de.death_date,de.death_cause_text,pt.moopart,pt.tmbpart,pt.amppart,pt.chwpart,ov.aid,
concat(pt.addrpart,' หมู่.',ov.moopart,' อ.',t3.name,' ต.',t2.name,' จ.',t1.name)as addressth,
odx.icd10,i.name
from vn_stat ov
left outer join opdscreen os on os.vn=ov.vn
left outer join ovst ovst on ovst.vn =ov.vn
left outer join pttype ptt on ptt.pttype = ov.pttype
left outer join death de on de.hn = ov.hn
left outer join ovstdiag odx on odx.hn=ov.hn
left outer join icd101 i on i.code = odx.icd10
left outer join patient pt on pt.hn=ov.hn
left outer join thaiaddress t1 on t1.chwpart=pt.chwpart and
t1.amppart="00" and t1.tmbpart="00"
left outer join thaiaddress t2 on t2.chwpart=pt.chwpart and
t2.amppart=pt.amppart and t2.tmbpart="00"
left outer join thaiaddress t3 on t3.chwpart=pt.chwpart and
t3.amppart=pt.amppart and t3.tmbpart=pt.tmbpart
left outer join nationality nn on nn.nationality = pt.nationality
left outer join occupation oc on oc.occupation = pt.occupation
where ov.vstdate between '2009-10-01' and '2009-10-01'
and os.bpd>='80' and os.bpd<='89'
and os.bps>='120' and os.bps<='139'
ตัวย่างที่ Export แล้วครับ
http://www.beupload.com/download/?750563&A=235487