BMS-HOSxP Community
HOSxP => Report Exchange => ข้อความที่เริ่มโดย: panus_t ที่ กรกฎาคม 16, 2013, 09:16:11 AM
-
ความต้องการ
1.แยกนอก-ในเวลาราชการ (นอกเวลา = วันหยุุดใน Holiday และวันปกติ ที่ไม่ใช้เวลา 08.00-16.00)
2.แยกผู้ป่วยนอก-ใน
3.ต้องการแค่จำนวนครับ (Select และ Count)
;D :D
select *
from xray_report x
left outer join holiday h on h.holiday_date=x.request_date
where x.request_date between "2013-07-01" and "2013-07-15" and h.holiday_date=x.request_date
-
1.นอก/ในเวลา
select count(x.vn) total
,sum(dayofweek(x.request_date) in (1,7)
or h.holiday_date is not null
or x.request_time<'08:00:00'
or x.request_time>'16:00:00') outtime
,sum(!(dayofweek(x.request_date) in (1,7)
or h.holiday_date is not null
or x.request_time<'08:00:00'
or x.request_time>'16:00:00')) intime
from xray_report x
left join holiday h on h.holiday_date=x.request_date
where x.request_date between '2013-1-1' and '2013-1-31'
2.OPD/IPD
select count(x.vn) total
,sum(length(an)<>9) 'OPD'
,sum(length(an)=9) 'IPD'
from xray_report x
where x.request_date between '2013-1-1' and '2013-1-31'
-
ขอบคุณครับ (กด Like แล้วไม่เห็นขึ้นชื่อผมเลย ท่านใดเป็นบ้าง หรือมีคำตอบเรื่องนี้หรือเปล่าครับ ;D)
-
ถ้าจะนำคำสั่ง SQL 2 ชุดนี้มาทำรายงานเป็นตัวเดียวกัน ทำยังไงครับ... ;D