BMS-HOSxP Community

HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: sahavej_pct ที่ ตุลาคม 09, 2015, 09:55:38 AM

หัวข้อ: คำสั่งนี้เราจะสามารถสรุปรวมค่าใช้จ่ายแต่ละคนที่ HN เหมือนกันได้อย่างไรครับ
เริ่มหัวข้อโดย: sahavej_pct ที่ ตุลาคม 09, 2015, 09:55:38 AM
select r.hn,concat(p.pname,p.fname,"  ",p.lname) as ptname,  r.*,o.vstdate,o.vsttime,t.name as pttype_name
from rcpt_arrear r
left outer join ovst o on o.vn=r.vn
left outer join patient p on p.hn=r.hn
left outer join pttype t on t.pttype = o.pttype
where r.arrear_date between '2014-10-01' and '2015-09-30'    and r.paid in ("N")
and t.pttype='24'
order by r.arrear_id

คำสั่งนี้เราจะสามารถสรุปรวมค่าใช้จ่ายแต่ละคนที่ HN เหมือนกันได้อย่างไรครับ
หัวข้อ: Re: คำสั่งนี้เราจะสามารถสรุปรวมค่าใช้จ่ายแต่ละคนที่ HN เหมือนกันได้อย่างไรครับ
เริ่มหัวข้อโดย: เกื้อกูล ครับ.. ที่ ตุลาคม 09, 2015, 12:06:12 PM
select r.hn,concat(p.pname,p.fname,"  ",p.lname) as ptname,  r.*,o.vstdate,o.vsttime,t.name as pttype_name
from rcpt_arrear r
left outer join ovst o on o.vn=r.vn
left outer join patient p on p.hn=r.hn
left outer join pttype t on t.pttype = o.pttype
where r.arrear_date between '2014-10-01' and '2015-09-30'    and r.paid in ("N")
and t.pttype='24'
order by r.arrear_id

คำสั่งนี้เราจะสามารถสรุปรวมค่าใช้จ่ายแต่ละคนที่ HN เหมือนกันได้อย่างไรครับ


select r.hn,concat(p.pname,p.fname,"  ",p.lname) as ptname,  r.*,o.vstdate,o.vsttime,t.name as pttype_name ,sum(amount) as total_money
from rcpt_arrear r
left outer join ovst o on o.vn=r.vn
left outer join patient p on p.hn=r.hn
left outer join pttype t on t.pttype = o.pttype
where r.arrear_date between '2014-10-01' and '2015-09-30'    and r.paid in ("N")  and t.pttype='24'
group by r.hn
order by r.hn