2
« เมื่อ: กุมภาพันธ์ 18, 2017, 11:54:47 AM »
ลองดูนะครับ น่าจะใช้คำสั่งประมาณนี้
select i.wtlos,concat(trim(p.pname) , trim(fname)," ",trim(lname)) as ptname ,i.vn,i.an,i.hn,i.regdate,i.dchdate,income,i.pttype,rcpno_list,bill_date_time,rcpt_money,debt_id_list,amount
,credit_card_amount ,
(select group_concat(rd.rcpno) from rcpt_print rd where rd.status = "ABORT" and rd.vn = a.an) as rcpt_abort ,
(select sum(rp.cash_amount) from rcpt_print rp where rp.status = "ABORT" and rp.vn = a.an ) as total_abort
from an_stat a
left outer join patient p on p.hn=a.hn
left outer join ipt i on i.an=a.an
left outer join dchtype dc on dc.dchtype=i.dchtype
left outer join rcpt_print rc on rc.vn=a.an
left outer join rcpt_debt bt on bt.vn=a.an
left outer join pttype t on t.pttype=a.pttype
where date(bill_date_time) between "2016-10-01" and "2016-10-10"
group by a.an