BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: jeab101 ที่ ตุลาคม 29, 2009, 21:39:38 PM

หัวข้อ: วานท่านเทพ..ช่วยแนะนำ คำสั่ง sql นี้ด้วยครับ
เริ่มหัวข้อโดย: jeab101 ที่ ตุลาคม 29, 2009, 21:39:38 PM
ผมต้องการหารายชื่อคนไข้ที่  "ได้รับคำแนะนำให้เลิกสูบบุหรี่"
ซึ่งผมได้เพิ่ม item ดังกล่าวไว้ที่ รายการค่ารักษาพยาบาล รหัส  icode='3900200'
ซึ่งผมได้ตามค้นหาปรากฏว่ามีข้อมูลบันทึกไว้ที่ตาราง "opitemrece_summary"

...ปัญหาคือ ในตารางดังกล่าวไม่มีฟิลด์ ที่ระบุตัวคนไข้เลยครับ เช่น HN ,ชื่อ-สกุล

ท่านเทพทั้งหลายโปรดช่วยแนะนำด้วยครับ ต้องเขียนคำสั่งว่ายังไงครับ
เพื่อให้ได้ HN ,ชื่อ-สกุล,วันที่มารับบริการ, ตามรหัส icode ดังกล่าว

ขอบคุณมากครับ

 
หัวข้อ: Re: วานท่านเทพ..ช่วยแนะนำ คำสั่ง sql นี้ด้วยครับ
เริ่มหัวข้อโดย: มดตานอย ครับ.. ที่ ตุลาคม 29, 2009, 21:59:14 PM
opitemrece     น่าจะมีนะครับ     hn

หัวข้อ: Re: วานท่านเทพ..ช่วยแนะนำ คำสั่ง sql นี้ด้วยครับ
เริ่มหัวข้อโดย: asawincyber ที่ ตุลาคม 29, 2009, 22:01:09 PM
select o.hn,concat(p.pname,p.fname,'  ',p.lname) as name,o.vstdate,o.icode from opitemrece o
left outer join patient p on p.hn =o.hn
where o.icode ="3900200" and o.vstdate  between "2009-01-01" and  "2009-01-31"
order by o.vstdate
หัวข้อ: Re: วานท่านเทพ..ช่วยแนะนำ คำสั่ง sql นี้ด้วยครับ
เริ่มหัวข้อโดย: jeab101 ที่ ตุลาคม 29, 2009, 22:48:17 PM
select o.hn,concat(p.pname,p.fname,'  ',p.lname) as name,o.vstdate,o.icode from opitemrece o
left outer join patient p on p.hn =o.hn
where o.icode ="3900200" and o.vstdate  between "2009-01-01" and  "2009-01-31"
order by o.vstdate

...ขอบคุณมากครับ...ได้เต็มๆเลย
หัวข้อ: Re: วานท่านเทพ..ช่วยแนะนำ คำสั่ง sql นี้ด้วยครับ
เริ่มหัวข้อโดย: doramon ที่ ตุลาคม 29, 2009, 23:49:04 PM
select o.hn,concat(p.pname,p.fname,'  ',p.lname) as name,o.vstdate,o.icode from opitemrece o
left outer join patient p on p.hn =o.hn
where o.icode ="3900200" and o.vstdate  between "2009-01-01" and  "2009-01-31"
order by o.vstdate

...ขอบคุณมากครับ...ได้เต็มๆเลย

ดีใจด้วยครับ

 :)