BMS-HOSxP Community

HOSxP => การเขียน SQL Script => ข้อความที่เริ่มโดย: thecoy ที่ มิถุนายน 15, 2009, 11:33:40 AM

หัวข้อ: หายอดจำนวนผู้ป่วยในแต่ละช่วงเวลา
เริ่มหัวข้อโดย: thecoy ที่ มิถุนายน 15, 2009, 11:33:40 AM
select o.vstdate ,count(o.vn) as  morning ,count(a.vn) as afternoon ,count(b.vn) as nigth
from ovst o
left outer join ovst a on a.vn=o.vn  and a.vsttime between'16:00:00' and '23:59:59'
left outer join ovst b on b.vn=o.vn  and b.vsttime between'00:00:00' and '07:59:59'
where o.vstdate between '2009-05-01' and'2009-05-31'
and o.vsttime between'08:00' and '15:59:59'
group by o.vstdate
 :Dมันออกจะเฉพาะ ช่วงเช้า ครับ บ่ายกับดึกไม่ออก  :D
หัวข้อ: Re: หายอดจำนวนผู้ป่วยในแต่ละช่วงเวลา
เริ่มหัวข้อโดย: woravet ที่ มิถุนายน 15, 2009, 11:45:50 AM
select o.vstdate
,count(o.vn) as amount
,sum(o.vsttime between '08:00:00' and '15:59:59') as morning
,sum(o.vsttime between '16:00:00' and '23:59:59') as afternoon
,sum(o.vsttime between '00:00:00' and '07:59:59') as nigth
from ovst o
where o.vstdate between '2009-05-01' and'2009-05-31'
group by o.vstdate
หัวข้อ: Re: หายอดจำนวนผู้ป่วยในแต่ละช่วงเวลา
เริ่มหัวข้อโดย: thecoy ที่ มิถุนายน 15, 2009, 11:49:48 AM
Thank you :D
หัวข้อ: Re: หายอดจำนวนผู้ป่วยในแต่ละช่วงเวลา
เริ่มหัวข้อโดย: kwh ที่ มิถุนายน 15, 2009, 13:12:28 PM
อันนี้มันผู้ป่วยนอกนิครับ  ;D
หัวข้อ: Re: หายอดจำนวนผู้ป่วยในแต่ละช่วงเวลา
เริ่มหัวข้อโดย: atit ที่ มิถุนายน 15, 2009, 14:55:16 PM
อันนี้มันผู้ป่วยนอกนิครับ  ;D

หายอดจำนวนผู้ป่วย  ในแต่ละช่วงเวลา
;D