BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: niwat ที่ พฤษภาคม 12, 2008, 20:59:33 PM
-
select b.hn,concat(pname,fname,' ',lname) as ptname,b.vstdate,b.icode,concat(a.name,' ',strength) as drugname,b.qty,a.units
from opitemrece b
left outer join drugitems a on a.icode=b.icode
left outer join patient c on b.hn=c.hn
where vstdate='2008-05-06'and'2008-05-06'
and (b.icode ='1000315'
or b.icode ='1000311'
or b.icode ='1000039'
or b.icode ='1500070'
or b.icode ='1000427'
or b.icode ='1000622'
or b.icode ='1000659'
or b.icode ='1000515'
or b.icode ='1000516'
or b.icode ='1000529'
or b.icode ='1000312'
or b.icode ='1000744'
or b.icode ='1000745'
or b.icode ='1000746'
or b.icode ='1000182')
order by icode
วันที่มันรันได้วันเดียวครับ และร่วมรัหสนาด้วยครับ ผมว่ามันไม่น่ายาวแบบนี้ครับ
-
select b.hn,concat(pname,fname,' ',lname) as ptname,b.vstdate,b.icode,concat(a.name,' ',strength) as drugname,b.qty,a.units
from opitemrece b
left outer join drugitems a on a.icode=b.icode
left outer join patient c on b.hn=c.hn
where vstdate='2008-05-06'and'2008-05-06'
and b.icode in ('1000315','1000311','1000039','1500070','1000427','1000622','1000659','1000515'
,'1000516','1000529','1000312','1000744','1000745','1000746','1000182')
order by icode
ทดสอบดูครับว่าเร็วขึ้นหรือเปล่าครับ
-
ยังมีปัญหาเรื่องวันที่ครับ where vstdate='2008-05-06'and'2008-05-06'มันจะรันได้วันที่ 6เดือน5ปี2008 วันเดียว พอเราแก้วันที่เป็น where vstdate='2008-05-01'and'2008-05-06'มันจะรันได้วันที่ 1เดือน5ปี 2008 วันเดียวอยู่ดี มันผิดตรงไหนครับช่วยดูอีกรอบหน่อยครับ
-
select b.hn,concat(pname,fname,' ',lname) as ptname,b.vstdate,b.icode,concat(a.name,' ',strength) as drugname,b.qty,a.units
from opitemrece b
left outer join drugitems a on a.icode=b.icode
left outer join patient c on b.hn=c.hn
where vstdate between '2008-05-02'and'2008-05-06'
and b.icode in ('1000315','1000311','1000039','1500070','1000427','1000622','1000659','1000515'
,'1000516','1000529','1000312','1000744','1000745','1000746','1000182')
order by icode ,vstdate
ได้แล้วครับ
-
เริ่มเก่งแล้วครับ ;D