นำคำสั่งไป Query แล้วก็มีข้อมูล ถอย version แล้วก็ยังไม่ออกครับ งงมาก
select o.vn,o.hn,concat(p.pname,p.fname," ",p.lname) as pt_name,p.cid,o.vstdate
,if(op.icode like "1%",concat(d.name,d.strength," ",d.units),nd.name) as drugname
,op.icode,op.qty,op.unitprice,op.sum_price,op.income,op.paidst
,if(op.paidst="01" or op.paidst="02",sum_price,null) as reim_amount
,if(op.paidst="03",sum_price,null) as not_reim_amount
,if(op.icode like "1%",if(op.paidst=03,"เบิกไม่ได้","เบิกได้"),concat("รหัส ",nd.billcode)) as reim_status
,i.name as income_name
from ovst o
inner join patient p on p.hn=o.hn
inner join opitemrece op on op.vn=o.vn
inner join income i on i.income=op.income
inner join income_report2 i2 on i2.group_id=i.group2
left outer join drugitems d on d.icode=op.icode
left outer join nondrugitems nd on nd.icode=op.icode
where o.pttype in("95") and o.vn="540710074941"
order by i2.group_id, op.income, op.item_no