BMS-HOSxP Community

HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: sulaiman_hosxp ที่ มิถุนายน 08, 2011, 13:55:52 PM

หัวข้อ: ช่วยแก้คำสั่ง MySQL หน่อยหน่อยครับ
เริ่มหัวข้อโดย: sulaiman_hosxp ที่ มิถุนายน 08, 2011, 13:55:52 PM
ต้องการให้ ข้อมูลในช่อง ruam  ให้แสดงเฉพาะ ข้อมูลที่ไม่เกิน 1 ชั่วโมงครับ

select a.vstdate,a.vn,a.hn,concat(pname,fname," ",lname) as ptname,
a.vsttime as begintime,
sec_to_time((time_to_sec(a.service6))-((time_to_sec(a.service5)-time_to_sec(a.service11))+(time_to_sec(a.service12)-time_to_sec(a.service5)))) as sed,
sec_to_time(((time_to_sec(a.service6))-((time_to_sec(a.service5)-time_to_sec(a.service11))+(time_to_sec(a.service12)-time_to_sec(a.service5))))-(time_to_sec(a.vsttime))) as ruam
from service_time a
left outer join patient b on a.hn=b.hn
left outer join ovst o on o.vn=a.vn
where a.vstdate between'2011-03-25'and'2011-03-25'
and o.visit_type="I"
and o.main_dep="010"
and o.ovstist="01"
and a.service4>a.vsttime
and a.service6>a.service4
and a.service12>a.service5
หัวข้อ: Re: ช่วยแก้คำสั่ง MySQL หน่อยหน่อยครับ
เริ่มหัวข้อโดย: patipan27 ที่ มิถุนายน 08, 2011, 14:06:19 PM
เพิ่มบรรทัดนี้เข้าไปครับ
and sec_to_time(((time_to_sec(a.service6))-((time_to_sec(a.service5)-time_to_sec(a.service11))+(time_to_sec(a.service12)-time_to_sec(a.service5))))-(time_to_sec(a.vsttime))) <='01:00:00'
หัวข้อ: Re: ช่วยแก้คำสั่ง MySQL หน่อยหน่อยครับ
เริ่มหัวข้อโดย: sulaiman_hosxp ที่ มิถุนายน 08, 2011, 14:14:52 PM
ขอบคุณครับ