select concat(pt.pname,pt.fname," ",pt.lname) as fullname,pt.hn,vns.pdx,icd.name,
concat(pt.addrpart," หมู่ ",pt.moopart," ต.",t3.name," อ.",t2.name," จ.",t1.name) as fulladdressname,
op.an,op.icode,d.name,d.strength,qty,year(rxdate)-year(birthday) as age,rxdate,order_no
from ovst ov
left outer join patient pt on pt.hn=ov.hn
left outer join thaiaddress t1 on t1.chwpart=pt.chwpart and
t1.amppart="00" and t1.tmbpart="00"
left outer join thaiaddress t2 on t2.chwpart=pt.chwpart and
t2.amppart=pt.amppart and t2.tmbpart="00"
left outer join thaiaddress t3 on t3.chwpart=pt.chwpart and
t3.amppart=pt.amppart and t3.tmbpart=pt.tmbpart
left outer join opitemrece op on op.hn=ov.hn
left outer join drugitems d on d.icode=op.icode
left outer join vn_stat vns on vns.vn=ov.vn
left outer join icd101 icd on icd.code=vns.pdx
where op.rxdate between "2008-10-31" and "2008-10-31" and op. icode in ('1000060','1440208','1500029','1510009','1510018','1510019','1510020')
group by order_no
ฝากเพิ่มวิธีการใช้ด้วยครับ (Shortlist)