BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: vinaisena ที่ กุมภาพันธ์ 22, 2011, 09:43:02 AM
-
อยากได้คำสั่ง ตัด HN ที่ซ้ำจาก SQL นี้ว่าจะต้องทำอย่างไรครับ รบกวนอาจารย์ทุกท่านด้วยครับ
select pt.*,ov.*
from vn_stat ov ,patient pt ,ovst ovst
where ov.vn=ovst.vn and pt.hn=ov.hn and ov.vstdate between "2009-10-01" and "2010-09-30" and ov.hn=pt.hn
and ov.age_y>= 0
and ov.age_y<= 200
and ( (ov.pdx >= "B200" and ov.pdx <= "B24")
or (ov.dx0 >= "B200" and ov.dx0 <= "B24")
or (ov.dx1 >= "B200" and ov.dx1 <= "B24")
or (ov.dx2 >= "B200" and ov.dx2 <= "B24")
or (ov.dx3 >= "B200" and ov.dx3 <= "B24")
or (ov.dx4 >= "B200" and ov.dx4 <= "B24")
or (ov.dx5 >= "B200" and ov.dx5 <= "B24") )
-
select distinct pt.hn,pt.*,ov.*
.........
........
ลองดูได้หรือเปล่าครับ
-
อย่าลืมเอา HN ตัวเองออกนะครับ ฮา.....
-
ยังซ้ำอยู่เหมือนเดิมครับ อาจารย์
-
ลองอันนี้ครับ...สด ๆ เดี๋ยวนี้เลย
select distinct pt.hn, concat(pt.pname,pt.fname," ",pt.lname) as pt_name
from ovstdiag odx
join vn_stat v on v.vn=odx.vn
join patient pt on pt.hn=v.hn
where (v.age_y>= 0 and v.age_y <= 200) and (odx.icd10 between "B20" and "B24") and (v.vstdate between "2010-01-01" and "2010-01-31")
order by pt.hn
-
select pt.*,ov.*
from vn_stat ov ,patient pt ,ovst ovst
where ov.vn=ovst.vn and pt.hn=ov.hn and ov.vstdate between "2009-10-01" and "2010-09-30" and ov.hn=pt.hn
and ov.age_y>= 0
and ov.age_y<= 200
and ( (ov.pdx >= "B200" and ov.pdx <= "B24")
or (ov.dx0 >= "B200" and ov.dx0 <= "B24")
or (ov.dx1 >= "B200" and ov.dx1 <= "B24")
or (ov.dx2 >= "B200" and ov.dx2 <= "B24")
or (ov.dx3 >= "B200" and ov.dx3 <= "B24")
or (ov.dx4 >= "B200" and ov.dx4 <= "B24")
or (ov.dx5 >= "B200" and ov.dx5 <= "B24") )
group by pt.hn
-
select pt.*,ov.*
from vn_stat ov ,patient pt ,ovst ovst
where ov.vn=ovst.vn and pt.hn=ov.hn and ov.vstdate between "2009-10-01" and "2010-09-30" and ov.hn=pt.hn
and ov.age_y>= 0
and ov.age_y<= 200
and ( (ov.pdx >= "B200" and ov.pdx <= "B24")
or (ov.dx0 >= "B200" and ov.dx0 <= "B24")
or (ov.dx1 >= "B200" and ov.dx1 <= "B24")
or (ov.dx2 >= "B200" and ov.dx2 <= "B24")
or (ov.dx3 >= "B200" and ov.dx3 <= "B24")
or (ov.dx4 >= "B200" and ov.dx4 <= "B24")
or (ov.dx5 >= "B200" and ov.dx5 <= "B24") )
group by pt.hn
แล้วถ้าจะดึง Vstdate มา วันแรกที่ visit ด้วยเงื่อนไขไหมครับ
-
ขอบคุณ อาจารย์ทุกท่านครับ จะเอาไป import ใน program napha ของงาน STD