BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: กระป๋อง ที่ ตุลาคม 29, 2010, 10:46:30 AM
-
อาจารย์ท่านไหนมีวิธีที่ดึงจำนวนผู้ป่วยนอกและผู้ป่วยในออกมาเป็นแต่ละช่วงเดือนตั้งแต่ปีงบประมาณ51-53บ้างครับ
ขอเป็นโค๊ดได้ก็ดีครับ
ขอบคุณครับ
-
ลองใช้ custom search ครับ ที่เมนูรายงานครับ
-
ได้มานานแล้ว ไม่รู้ของอ.ท่านใดนะครับ แต่ก็ทดสอบในตาราง vn_stat ก็ได้นะครับ
set @t1 = unix_timestamp('2008-10-01');
set @t2 = unix_timestamp('2009-09-30');
select "OPD" as type, year(vstdate)+543 year, case month(vstdate)
when '1' then 'ม.ค.'
when '2' then 'ก.พ.'
when '3' then 'มี.ค.'
when '4' then 'เม.ย.'
when '5' then 'พ.ค.'
when '6' then 'มิ.ย.'
when '7' then 'ก.ค.'
when '8' then 'ส.ค.'
when '9' then 'ก.ย.'
when '10' then 'ต.ค.'
when '11' then 'พ.ย.'
when '12' then 'ธ.ค.'
end as month, count(distinct hn) as count_hn , count(vn) as count
from vn_stat
where unix_timestamp(vstdate) between @t1 and @t2
group by year(vstdate), month(vstdate)
union
select "IPD" as type, year(regdate)+543 year, case month(regdate)
when '1' then 'ม.ค.'
when '2' then 'ก.พ.'
when '3' then 'มี.ค.'
when '4' then 'เม.ย.'
when '5' then 'พ.ค.'
when '6' then 'มิ.ย.'
when '7' then 'ก.ค.'
when '8' then 'ส.ค.'
when '9' then 'ก.ย.'
when '10' then 'ต.ค.'
when '11' then 'พ.ย.'
when '12' then 'ธ.ค.'
end as month, count(distinct hn) as count_hn , count(an) as count
from an_stat
where unix_timestamp(regdate) between @t1 and @t2
group by year(regdate), month(regdate)
-
ขอบคุณมากครับ
แต่ทำไม custom search กับการ count และจำนวนยอดผู้ป่วยได้ไม่เท่ากัน ???
-
ในส่วนผม ข้อมูลตรงนะครับ ผม q ดูใน vn_stat ก็ได้ผลเดียวกัน กำหนดเงื่อนไขเพียง วันเริ่มต้นกับวันสุดท้ายพอครับ ลองดูอีกครั้งนะครับ
-
คน กับ ครั้ง อาจไม่จำเป็นต้องเท่ากัน หากว่า 1 คนมามากกว่า 1 ครั้ง ภายในเดือน หรือในช่วงที่มีการสั่งประมวลผลรายงาน... :D
-
ลองดูใหม่แล้วครับได้แล้วครับ
ขอบคุณมากครับ