ต้องการให้ ข้อมูลในช่อง 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