3
« เมื่อ: สิงหาคม 08, 2013, 20:28:55 PM »
ลองดูครับ
select distinct(h.hn),pt.cid,concat(pt.pname,pt.fname,' ',pt.lname) as name,
v.vstdate,concat(h.form_name,' ',o.lab_order_result) as FBS,v.pdx,v.dx0 ,v.dx1
from lab_order o
left outer join lab_head h on h.lab_order_number =o.lab_order_number
left outer join patient pt on h.hn=pt.hn
left outer join vn_stat v on v.hn=h.hn
where o.lab_order_result < 7 and v.vstdate between '2013-03-01' and '2013-03-31' and h.form_name ='HbA1c'
and ( (v.pdx >= "E100" and v.pdx <= "E119")
or (v.dx0 >= "E100" and v.dx0 <= "E119")
or (v.dx1 >= "E100" and v.dx1 <= "E119")
or (v.dx2 >= "E100" and v.dx2 <= "E119")
or (v.dx3 >= "E100" and v.dx3 <= "E119")
or (v.dx4 >= "E100" and v.dx4 <= "E119")
or (v.dx5 >= "E100" and v.dx5 <= "E119") )
group by v.hn