BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: shukree ที่ มิถุนายน 15, 2014, 23:15:40 PM
-
สมมุติต้องการหา มูลค่าการใช้ยา จากมากไปน้อย เช่น
select o.icode,sum(o.sum_price) as total,sum(o.qty) as total2,d.strength
from opitemrece o,drugitems d
where rxdate between "2014-05-01" and "2014-05-30"
and o.icode = d.icode
group by o.icode
order by total desc
limit xxx
ถ้าเราจะกำหนดผู้เรียกใช้รายงานกำหนด limit เอง(xxx)เวลาเรียกใช้
เช่นใช้ inputquery
ไม่ทราบว่าต้องเขียนอย่างไรครับ
-
ลองศึกษาจากกระทู้นี้ดูครับ http://hosxp.net/index.php?option=com_smf&topic=12919
-
คือจะเอาค่าจาก inputquery มาแทนค่าใน xxx ครับ คืออ่านจากกระทู้งงๆอยู่ครับ
-
ลองดูที่ อ.ขวด แนะนำไว้ครับ ตามรูปเลย
1. ประกาศตัวแปร เช่น ชื่อ copy (เหมือน อ.ขวด)
2. ใช้ copy:=inputquery('title','text');
3. แก้ไขตรง GlobalOnCreate
ChangeReportSQL('select o.icode,sum(o.sum_price) as total,sum(o.qty) as total2,d.strength '+
' from opitemrece o,drugitems d '+
' where rxdate between "2014-05-01" and "2014-05-30" '+
' and o.icode = d.icode '+
' group by o.icode '+
' order by total desc '+
limit "'+copy+'" ');
-
ลองใส่ดูแล้ว เป็นแบบนี้ครับ
-
ลองศึกษาดูจากตัวอย่างรายงานนี้นะครับ
-
ขอบคุณครับ
เผอิญผมใส่ฟันหนูเพิ่มครับ