ช่วยผมด้วยครับทำมัยยังมีผู้ป่วยซ้ำกันอยู่ผมผิดตรงไหนครับ...
select distinct pt.hn,ov.hospmain,ov.vstdate,pt.cid,pt.pname,pt.fname,pt.lname,pt.birthday,ov.age_y,
pt.sex,os.bw,os.height,concat(os.bpd,"/",os.bps)as mmhg,pt.addrpart,pt.moopart,pt.tmbpart,pt.amppart,pt.chwpart,
concat(pt.addrpart,"Á.",pt.moopart,' '," µ.",t3.name,' ',"Í.",t2.name,' '," ¨.",t1.name)
as fulladdressname,pt.nationality,ov.pdx,i.name
from vn_stat ov
left outer join opdscreen os on os.hn=ov.hn
left outer join patient pt on pt.hn=ov.hn
left outer join ovst ovst on ovst.hn =ov.hn
left outer join icd101 i on i.code = ov.main_pdx
left outer join pttype ptt on ptt.pttype = ov.pttype
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
where ov.vn>="500101000000" and ov.vn<="5033199999"
and ov.age_y>= 0
and ov.age_y<= 200
and ( (ov.pdx >= "I10" and ov.pdx <= "I159")
or (ov.pdx >= "e10" and ov.pdx <= "e149")
or (ov.pdx >= "j40" and ov.pdx <= "j479")
or (ov.pdx >= "i60" and ov.pdx <= "i699")
or (ov.pdx >= "i20" and ov.pdx <= "I259"))
limit 10
ขอบคุณล่วงหน้าครับ