ผมเขียนรายงานคิวรี่ ตรวจสุขภาพเจ้าหน้าที่ แล้ว รัน มาช้า มา รันที่ละ 1 vn ช้า มาก คสรปรับแต่ง ยังไง ครับ
select vn.hn,concat(pt.pname,pt.fname,' ',pt.lname)as name,vn.age_y,vn.vstdate as dd_mm_yyy,
pt.birthday, p.name as pttype , op.bps ,op.bpd ,op.bw,op.height,op.bmi,
lo.lab_order_result as FBS,
lo1.lab_order_result as CHOLESTEROL,
lo2.lab_order_result as TRIGLYCERIDE,
lo3.lab_order_result as BUN,
lo4.lab_order_result as CREATININE,
lo5.lab_order_result as SGOT ,
lo6.lab_order_result as SGPT ,
lo7.lab_order_result as ALKALINE_PHOSPHATASE ,
lo8.lab_order_result as URIC_ACID
from vn_stat vn
left outer join patient pt on vn.hn = pt.hn
left outer join lab_head lh on vn.vn =lh.vn
left outer join lab_order lo on lh.lab_order_number = lo.lab_order_number
left outer join lab_order lo1 on lh.lab_order_number = lo1.lab_order_number
left outer join lab_order lo2 on lh.lab_order_number = lo2.lab_order_number
left outer join lab_order lo3 on lh.lab_order_number = lo3.lab_order_number
left outer join lab_order lo4 on lh.lab_order_number = lo4.lab_order_number
left outer join lab_order lo5 on lh.lab_order_number = lo5.lab_order_number
left outer join lab_order lo6 on lh.lab_order_number = lo6.lab_order_number
left outer join lab_order lo7 on lh.lab_order_number = lo7.lab_order_number
left outer join lab_order lo8 on lh.lab_order_number = lo8.lab_order_number
left outer join pttype p on pt.pttype = p.pttype
left outer join opdscreen op on vn.vn = op.vn
where vn.vn = '550823063742'
and (lo.lab_items_code in ('88','89')
or lo1.lab_items_code = ('127')
or lo2.lab_items_code = ('125')
or lo3.lab_items_code = ('100')
or lo4.lab_items_code = ('39')
or lo5.lab_items_code = ('134')
or lo6.lab_items_code = ('135')
or lo7.lab_items_code = ('136')
or lo8.lab_items_code = ('160') )
group by vn.hn