BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: arr_012 ที่ กรกฎาคม 02, 2010, 11:59:11 AM
-
ผมใช้สั่งสัง {select hn from ovstdiag
where icd10="i64"and hn in(select hn from vn_stat v
where v.pdx="i64"and v.vstdate <="2010-06-31"
group by v.hn having count(v.hn))and vstdate between"2010-01-01"and"2010-01-31" group by hn}
ใช้ทำรายงาน มันทำให้ server แฮ้งไปเลย ไม่รู้ว่าเกิดจากอะไรครับ
-
ยังไม่ค่อยเข้าใจคำสั่งที่เขียนขึ้่น แต่น่าจะแปลได้ประมาณนี้ (หรือเปล่าครับ)
select hn, count(hn) from ovstdiag
where icd10="I64"
and vstdate between "2010-01-01" and "2010-01-31"
group by hn
having count(hn)>2
-
มันผิดตรงนี้ >>>>> { select หรือป่าวคับ
-
มันผิดตรงนี้ >>>>> { select หรือป่าวคับ
"{}"อันนี้ผมไม่ได้ใส่ในคำสั่งที่จะใช้ครับ
-
คือว่า ผมต้องการคนใข้ที่ ที่หมอ diagเป็นโรค I64 เป็นครั้งแลกที่คนใข้มารับบริการกับโรงพยาบาล โดยที่เป็นคนใข้ในเดือนมิถุนายน ด้วย ครับ
-
หรือว่าจะเป็นเงื่อนไข คือ select distinct(p. hn ),o.vstdate,o.icd10 from ovstdiag o,patient p
where p.hn=o.hn and p.firstday=o.vstdate and o. icd10 like "I64%" and o.vstdate between "2010-06-01" and "2010-06-30" group by hn
order by p.hn,o.vstdate หรือเปล่าครับ
-
select * from ovstdiag o where o.icd10 between "I64" and "I649"
and o.vstdate between "2010-05-01" and "2010-05-31" and o.hn not in
(select hn from ovstdiag where icd10 between "I64" and "I649" and vstdate < 2010-05-01 and hn=o.hn)
ลองคำสั่งนี้ดูครับ
ข้อมูล Diag I64-I649
วันที่รับบริการเปลี่ยนแปลงได้
ส่วน SubQuery ควรมีข้อมูลน้อย ๆ นะครับ ถ้าเขียน Sub Query ที่มีข้อมูลขนาดใหญ่มากจะทำให้ค้างได้ ;D
-
select * from ovstdiag o where o.icd10 between "I64" and "I649"
and o.vstdate between "2010-05-01" and "2010-05-31" and o.hn not in
(select hn from ovstdiag where icd10 between "I64" and "I649" and vstdate < 2010-05-01 and hn=o.hn)
ลองคำสั่งนี้ดูครับ
ข้อมูล Diag I64-I649
วันที่รับบริการเปลี่ยนแปลงได้
ส่วน SubQuery ควรมีข้อมูลน้อย ๆ นะครับ ถ้าเขียน Sub Query ที่มีข้อมูลขนาดใหญ่มากจะทำให้ค้างได้ ;D
ครับผม
-
ต้องขอบคุณ พี่วรเวทย์ รพ.บึงสามัคคี กำแพงเพชร คับ
select * from (select o.hn,min(o.vstdate) vstdate,o.icd10 from ovstdiag o
where o.icd10 ="I259"and o.diagtype="1" group by o.hn) test
where vstdate between "2010-06-01" and "2010-06-30"
order by hn
ตรงตามที่ต้องการเลย ครับ
โยดยพี่เด่นชัย รพ.ไทรน้อย ที่ให้ความช่วยเหลือ มาก ครับ และพี่ทุกท่านที่ส่งมอบความรู้ให้ผม*-*