ช่วยดู SQL ผู้ป่วยซึมเศร้าที่เป็น Ht Dm ถูกรึเปล่าครับ
ผมเขียนแบบนี้ถูกรึป่าวครับ
SELECT
v.vn,
v.hn,
CONCAT(p.pname,' ',fname,' ',lname) AS ptname,
v.pdx,
v.dx0,
v.dx1,
v.dx2,
v.dx3,
v.dx4,
v.dx5,
v.spclty
FROM vn_stat v
LEFT OUTER JOIN patient p ON v.hn = p.hn
WHERE vstdate BETWEEN '2013-10-01' AND '2014-09-30'
and ((pdx BETWEEN "F320" and "F329")
or (dx0 >= "E10" and dx0 <= "E149")
or (dx1 >= "E10" and dx1 <= "E149")
or (dx2 >= "E10" and dx2 <= "E149")
or (dx3 >= "E10" and dx3 <= "E149")
or (dx4 >= "E10" and dx4 <= "E149")
or (dx5 >= "E10" and dx5 <= "E149"))
AND
((pdx BETWEEN "F320" and "F329")
or (v.dx0 between "I10" and "I159")
or (v.dx1 between "I10" and "I159")
or (v.dx2 between "I10" and "I159")
or (v.dx3 between "I10" and "I159")
or (v.dx4 between "I10" and "I159")
or (v.dx5 between "I10" and "I159"))
GROUP BY v.vn
ผลที่ได้คือ pdx มี dx อื่นๆ มาด้วยครับ