15
« เมื่อ: กรกฎาคม 12, 2011, 17:51:59 PM »
select ov.vn,ov.vstdate,pt.hn,concat (pt.pname,' ',pt.fname,' ',pt.lname) as ptname,ov.age_y,os.bw,os.height,os.bmi,
os.fbs,os.bps,os.bpd,pt.addrpart,pt.moopart,ta.full_name,concat (ov.pdx) as pdx,concat (ov.dx0) as dx0,
concat (ov.dx1) as dx1,concat (ov.dx2) as dx2,concat (ov.dx3) as dx3,concat (ov.dx4) as dx4,concat (ov.dx5) as dx5 ,
lh.lab_order_number,
l1.lab_order_result,l2.lab_order_result,l3.lab_order_result,l4.lab_order_resultfrom vn_stat ov
left outer join patient pt on pt.hn=ov.hn
left outer join ovst ovst on ov.vn=ovst.vn
left outer join thaiaddress ta on ov.aid=ta.addressid
left outer join icd101 icd on icd.code=ov.pdx
left outer join opdscreen os on os.vn=ov.vn
left outer join lab_head lh on lh.vn=ov.vn
left outer join lab_order l1 on l1.lab_order_number = lh.lab_order_number and l1.lab_items_code = '78'
left outer join lab_order l2 on l2.lab_order_number = lh.lab_order_number and l1.lab_items_code = '92'
left outer join lab_order l3 on l3.lab_order_number = lh.lab_order_number and l1.lab_items_code = '193'
left outer join lab_order l4 on l4.lab_order_number = lh.lab_order_number and l1.lab_items_code = '400'where ov.vstdate between "2011-05-01" and "2011-05-31"
and ov.aid<>"300301"
and ( (ov.pdx >= "E100" and ov.pdx <= "E119")
or (ov.dx0 >= "E100" and ov.dx0 <= "E119")
or (ov.dx1 >= "E100" and ov.dx1 <= "E119")
or (ov.dx2 >= "E100" and ov.dx2 <= "E119")
or (ov.dx3 >= "E100" and ov.dx3 <= "E119")
or (ov.dx4 >= "E100" and ov.dx4 <= "E119")
or (ov.dx5 >= "E100" and ov.dx5 <= "E119") )
order by pt.tmbpart , pt.moopart , pt.addrpart
ลองดูนะครับ