BMS-HOSxP Community
		HOSxP => Report Exchange => ข้อความที่เริ่มโดย: oley_01 ที่ กรกฎาคม 05, 2013, 15:21:58 PM
		
			
			- 
				ขอรายงาน รายละเอียดค้างชำระหน่อยครับ ใครพอมีบ้างครับ scrip ก็ได้ครับ ของผมมีแต่ออกไม่ตรงครับ (เป็นเฉพาะบางคนนะครับ)
select i.vstdate,i.hn,o.hospmain,ptt.pcode,ptt.name pttname, 
 concat(h.hosptype,h.name) as hname,i.pdx,i.inc01,i.inc02,i.inc03,i.inc04,i.inc05, 
 i.inc06,i.inc07,i.inc08,i.inc09,i.inc10,i.inc11,i.inc12,i.inc13,i.inc14, 
 i.inc15,i.inc16,i.inc17,i.income,i.inc_drug,i.inc_nondrug,p.cid,i.pttype, 
 (i.inc03+i.inc04+i.inc17) as drug,concat(p.pname,p.fname," ",p.lname) as ptname,i.vn,r.* 
from vn_stat i 
 left outer join ovst o on o.vn=i.vn 
 left outer join patient p on p.hn=i.hn 
 left outer join pttype ptt on ptt.pttype=i.pttype 
 left outer join hospcode h on h.hospcode=o.hospmain  
 left outer join rcpt_arrear r on r.vn=o.vn 
 where i.vstdate between "'2013-01-01'" and "'2013-01-31'" and i.paid_money = i.remain_money 
 and r.paid="N" 
 and r.pt_type="opd" and r.rcpno ="" 
 group by i.vn 
 order by i.vstdate