BMS-HOSxP Community

HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: shukree ที่ พฤศจิกายน 13, 2010, 22:53:53 PM

หัวข้อ: ขอความช่วยเหลือเรื่องรายงาน
เริ่มหัวข้อโดย: shukree ที่ พฤศจิกายน 13, 2010, 22:53:53 PM
อยากให้สามารถเลือกปีงบประมาณ 2554 ได้ด้วยครับ
หัวข้อ: Re: ขอความช่วยเหลือเรื่องรายงาน
เริ่มหัวข้อโดย: smrmpo ที่ พฤศจิกายน 13, 2010, 23:05:36 PM
('select "2554" union (select *********)');

พอเข้าใจมั้ยครับ เอา 2554 ไป รวม กับ คำสั่ง sql ที่ มีอยู่ครับ
หัวข้อ: Re: ขอความช่วยเหลือเรื่องรายงาน
เริ่มหัวข้อโดย: shukree ที่ พฤศจิกายน 14, 2010, 00:10:17 AM
แฮะ แฮะ ไม่เข้าใจครับ
ไม่ทราบว่าเพิ่มตรงไหนครับ

begin


     d1 :=GetSQLDateData('select min(vstdate) from ovst');
     d2 :=GetSQLDateData('select max(vstdate) from ovst');
     ds1 := formatdatetime('yyyy-mm-dd',d1);
     ds2 := formatdatetime('yyyy-mm-dd',d2);

     fyear := GetPickupList('select distinct(year(vstdate)) + 543 as cc ,vstdate  from ovst'+
                  ' where vstdate between "'+ds1+'" and "'+ds2+'"'+
                  ' group by cc'+
                  ' order by cc desc' );
     year := fyear;
     fyear := inttostr(strtoint(fyear) - 543) ;

     fyear := inttostr(strtoint(fyear) - 1) ;

     m10 := fyear+'-10-01" and "'+ fyear+'-10-31';
     m11 := fyear+'-11-01" and "'+ fyear+'-11-30';
     m12 := fyear+'-12-01" and "'+ fyear+'-12-31';

     fyear := inttostr(strtoint(fyear) + 1) ;

     m1 :=  fyear+'-01-01" and "'+ fyear+'-01-31';
     m2 := GetSQLStringData('select Date_Add("'+ fyear+'-01-31",interval 1 month) as d');
     m2 := fyear+'-02-01" and "'+ m2 ;

     
     m3 := fyear+'-03-01" and "'+ fyear+'-03-31';

     m4 := fyear+'-04-01" and "'+ fyear+'-04-30';
     m5 := fyear+'-05-01" and "'+ fyear+'-05-31';
     m6 := fyear+'-06-01" and "'+ fyear+'-06-30';
     m7 := fyear+'-07-01" and "'+ fyear+'-07-31';
     m8 := fyear+'-08-01" and "'+ fyear+'-08-31';
     m9 := fyear+'-09-01" and "'+ fyear+'-09-30';


     
end;
หัวข้อ: Re: ขอความช่วยเหลือเรื่องรายงาน
เริ่มหัวข้อโดย: smrmpo ที่ พฤศจิกายน 14, 2010, 00:29:33 AM
  fyear := GetPickupList('select "2554" union (select distinct(year(vstdate)) + 543 as cc ,vstdate  from ovst'+
                  ' where vstdate between "'+ds1+'" and "'+ds2+'"'+
                  ' group by cc'+
                  ' order by cc desc)' );

น่าจะประมาณนี้ครับ ตัวสีแดงคือส่วนที่ต้องเพิ่ม
 
หัวข้อ: Re: ขอความช่วยเหลือเรื่องรายงาน
เริ่มหัวข้อโดย: shukree ที่ พฤศจิกายน 14, 2010, 01:22:48 AM
compile แล้วไม่ผ่านตรับ
หัวข้อ: Re: ขอความช่วยเหลือเรื่องรายงาน
เริ่มหัวข้อโดย: smrmpo ที่ พฤศจิกายน 14, 2010, 01:33:33 AM
ตัวนี้ครับ ใช้ได้
fyear := GetPickupList('select "2554" union (select distinct(year(vstdate)) + 543 as cc from ovst '+
                  ' where vstdate between "'+ds1+'" and "'+ds2+'" '+
                  ' group by cc '+
                  ' order by cc desc)');
ต้องลบตัวสีแดงออก
select distinct(year(vstdate)) + 543 as cc ,vstdate   from ovst'+

นี่รูปที่ test


หัวข้อ: Re: ขอความช่วยเหลือเรื่องรายงาน
เริ่มหัวข้อโดย: shukree ที่ พฤศจิกายน 14, 2010, 01:46:22 AM
ได้แล้วครับ ขอบคุณครับ
หัวข้อ: Re: ขอความช่วยเหลือเรื่องรายงาน
เริ่มหัวข้อโดย: smrmpo ที่ พฤศจิกายน 14, 2010, 01:49:11 AM
เราสามารถ เอา union มาเชี่อม ตัวเลือกอีกหลายตัวก็ได้นะครับ ต้องลองดู ครับ ใช้ประโยชน์ได้เยอะ เลยครับ
ไปนอนแล้วครับ