มี sql ดิบมั้ยครับ
select pt.hn,concat(pt.pname,pt.fname,' ',pt.lname) as ptname ,ov.vstdate, pt.cid , pt.occupation , ovst.vsttime , er.er_dch_type , ov.age_y , er.er_emergency_type , er.vn
from vn_stat ov ,patient pt ,ovst ovst ,er_regist er , er_nursing_detail dl
where ov.vn=ovst.vn and pt.hn=ov.hn and er.vn=ov.vn and dl.vn=ov.vn
and ov.vstdate between "2011-01-01" and "2011-12-31"
and ov.hn=pt.hn
and er.er_pt_type = "2"
and ( (ov.pdx >= "v00" and ov.pdx <= "v99")
or (ov.dx0 >= "v00" and ov.dx0 <= "v99")
or (ov.dx1 >= "v00" and ov.dx1 <= "v99")
or (ov.dx2 >= "v00" and ov.dx2 <= "v99")
or (ov.dx3 >= "v00" and ov.dx3 <= "v99")
or (ov.dx4 >= "v00" and ov.dx4 <= "v99")
or (ov.dx5 >= "v00" and ov.dx5 <= "v99") )
and ( er.er_emergency_type = "1"
or er.er_emergency_type = "2"
or er.er_dch_type = "4")
group by pt.hn
order by er.vstdate