19
« เมื่อ: พฤศจิกายน 28, 2016, 12:31:48 PM »
สอบถามครับ คำสั่งนี้ เราจะเอา Field ที่ชื่อ ว่า (paid_momey-bill_amount-credit_card_amount-amount) = ได้ผลลัพธ์ ต้องเพิ่มคำสั่งตรงไหนครับ..ขอบคุณครับ
select ov.*, substring(concat(oost.name,' [',sp.department,']'),1,150)
as ovstname, odx.icd10
as icdcode, vk.vn
as lock_vn,pt.birthtime, substring(icd1.name,1,100)
as icdname, concat(odx.icd10,' ',ix.name)
as pdxname ,pt.birthday, pty.pcode, st.name
as ovstist_name, concat(pt.pname,' ',pt.fname,' ',pt.lname)
as ptname, oapp.nextdate
as ndate,vt.age_y,vt.age_m,vt.age_d , vt.cid,c.complete,vt.pttype_in_region,vt.inc_drug,vt.count_in_day+1
as count_in_day , od.rw ,pty.name,ovq.promote_visit,vt.paid_money,rc.bill_amount,bt.amount,credit_card_amount,rc.rcpno,p.reason
from ovst ov
left outer join patient pt on pt.hn=ov.hn
left outer join rcpt_abort p on p.vn=ov.vn
left outer join ovstdiag odx on odx.vn=ov.vn and odx.diagtype='1'
left outer join kskdepartment sp on sp.depcode=ov.cur_dep
left outer join ovstost oost on oost.ovstost=ov.ovstost
left outer join icd101 icd1 on icd1.code=odx.icd10
left outer join icd101 ix on ix.code=substring(odx.icd10,1,3)
left outer join pttype pty on pty.pttype=ov.pttype
left outer join vn_lock vk on vk.vn = ov.vn
left outer join ovstist st on st.ovstist = ov.ovstist
left outer join vn_stat vt on vt.vn=ov.vn
left outer join rcpt_print rc on rc.vn=ov.vn
left outer join rcpt_debt bt on bt.vn=ov.vn
left outer join ovst_drgs od on od.vn=ov.vn
left outer join oapp on oapp.vn=ov.vn and oapp.app_no=1
left outer join vn_opd_complete c on c.vn=ov.vn
left outer join ovst_seq ovq on ovq.vn = ov.vn
where (ov.vstdate between '2016-11-24' and '2016-11-24')