SQL Code ที่แก้ไข
select r.*,d.*,i.name as income_name,
d.amount as detail_amount,concat(p.pname,p.fname," ",p.lname) as full_name,
pt.name as pttype_name,op.name as staff_name,op.entryposition,ops.icode,
sd.name as sd_name,ops.qty,ops.sum_price,o.paidst
from rcpt_debt r
left outer join rcpt_debt_detail d on d.debt_id=r.debt_id
left outer join income i on i.income=d.income
left outer join patient p on p.hn=r.hn
left outer join pttype pt on r.pttype=pt.pttype
left outer join opduser op on op.loginname=r.staff
left outer join opitemrece_summary ops on ops.vn=r.vn and ops.income=d.income
left outer join s_drugitems sd on sd.icode=ops.icode
left outer join opitemrece o on o.hos_guid=ops.hos_guid
where r.debt_id=10802
order by ops.income
ปราณี มีเกาะ
BMS-Call Center