BMS-HOSxP Community

HOSxP => การเขียน SQL Script => ข้อความที่เริ่มโดย: Bluebird ที่ มกราคม 19, 2016, 09:13:06 AM

หัวข้อ: แสดงเลขที่คิว ตามข้อมูลการนัดหมายแต่ล่ะคลินิก
เริ่มหัวข้อโดย: Bluebird ที่ มกราคม 19, 2016, 09:13:06 AM
value:=GetSQLStringData('select distinct count(hn)as chn  '+
                        'from oapp        '+
                        'where nextdate = "'+DBPipeline['nextdate']+'"  '+
                        'and clinic="'+DBPipeline['clinic']+'" '+
                        'and oapp_id <= "'+DBPipeline['oapp_id']+'"  ');

ลองทดสอบ Query เลขที่ออกอยู่ แต่พอไปใส่ใน Variable ปรากฏว่าเป็น 0
หัวข้อ: Re: แสดงเลขที่คิว ตามข้อมูลการนัดหมายแต่ล่ะคลินิก
เริ่มหัวข้อโดย: golf_win ที่ มกราคม 19, 2016, 13:13:36 PM
แบบนี้พอได้มั้ยครับ


หัวข้อ: Re: แสดงเลขที่คิว ตามข้อมูลการนัดหมายแต่ล่ะคลินิก
เริ่มหัวข้อโดย: golf_win ที่ มกราคม 19, 2016, 13:14:35 PM
คำสั่งก็ประมาณนี้ครับ

Var
a := String;

a := GetSQLStringData('select oapp_id from oapp where nextdate="'+FormatDateTime('yyyy-mm-dd',DBPipeline['nextdate'])+'" '+
  ' and clinic="'+DBPipeline['clinic']+'"  '+
  ' order by oapp_id limit 1 ');
 
  Value := GetSQLStringData('select count(oapp_id) as cc from oapp where '+
  ' nextdate="'+FormatDateTime('yyyy-mm-dd',DBPipeline['nextdate'])+'" '+
  ' and clinic="'+DBPipeline['clinic']+'" and oapp_id between "'+a+'" and "'+DBPipeline['oapp_id']+'" '+
  ' order by oapp_id ');
หัวข้อ: Re: แสดงเลขที่คิว ตามข้อมูลการนัดหมายแต่ล่ะคลินิก
เริ่มหัวข้อโดย: Bluebird ที่ มกราคม 19, 2016, 15:51:46 PM
ขอบคุณครับ