BMS-HOSxP Community
HOSxP => Report Exchange => ข้อความที่เริ่มโดย: s@u ที่ กุมภาพันธ์ 09, 2010, 10:29:47 AM
-
จะนับ hn แยกตามสิทธิ์ แต่เขียนแล้วมันก็ออกมาเป็น 0 รบกวนช่วยดูให้หน่อยค่ะ
select count(distinct(d.hn)) as c_hn
from dtmain d
left outer join patient_regiment p on p.hn=d.hn
left outer join regiment_type r on r.regiment_type=p.regiment_type
where d.vstdate between '01-12-2009' and '31-12-2009'
and p.regiment_type in (2,8)
ตาราง regiment_type
จะแยกสิทธิ์ตามรายการด้านล่างค่ะ
ก1 : 2,8
ก2 : 1,6,10,11,15,16,17,19
ข1 : 13
ข2 : 7
ค1 : 4
ค2 : 3,5,8,9,12,14
-
เหลือแต่ตรง สถิติจำแนกตามประเภทผู้ป่วย
-
ลองดูครับ ผมแก้ตรง select count(distinct(d.hn)) as c_hn
from dtmain d
left outer join patient_regiment p on p.hn=d.hn
left outer join regiment_type r on r.regiment_type=p.regiment_type
where d.vstdate between '01-12-2009' and '31-12-2009'
and p.regiment_type in ("2","8")
-
ขอบคุณค่ะ เดี๋ยวจะลองทดสอบดูค่ะ
-
ได้แล้วค่ะ ขอบคุณมากๆ ค่ะ
-
ขอลองเอาไปใช้ดูหน่อยนะครับ