ลองเปลี่ยน select d1.* เป็น
select d1.doctor_order_print_code,d1.vn,
d1.doctor_code,
d1.doctor_order_print_date_time,
d1.patient_name,d1.drug_name,
d1.qty_name,d1.line1,
d1.line2,d1.line3,
d1.shortlist,d1.line4,
d1.print_status,d1.hn,
d1.print_server,d1.item_price,
d1.qty_int,d1.patient_age,
d1.patient_pttype_name,d1.patient_address,
d1.doctor_name,d1.diagnosis_name,
d1.patient_type,d1.print_date,
d1.print_time,d1.ward_name,
d1.bed_no,d1.staff,
d1.rx_queue,d1.print_mode,
d1.item_no,d1.dep_name,
d1.orderstatus,d1.icode,
d1.order_no,d1.pttype,
d1.print_count,
v1.vn,o1.vn,if(ward_name="ยานอกบัญชียาหลักแห่งชาติ","NED","") as drugtype
from doctor_order_print d1
left outer join vn_stat v1 on v1.vn=d1.vn
left outer join ovst o1 on o1.vn=d1.vn
where d1.vn="541220071243" and d1.print_server="IPD1"
and d1.qty_int>0