REPORTFORM;PU8.frf
TITLE;รายงานแสดงยอดซื้อทั้งปี  ตามรหัสผู้จำหน่าย
SQL;select invcard.ACCID, apmst.XCOMP,sum(invcard.SALEPURAMT)as XTOTAL,
SQL;sum(if(MONTH(invcard.DATEDOC)=1,invcard.SALEPURAMT,0)) as MTH1,
SQL;sum(if(MONTH(invcard.DATEDOC)=2,invcard.SALEPURAMT,0)) as MTH2,
SQL;sum(if(MONTH(invcard.DATEDOC)=3,invcard.SALEPURAMT,0)) as MTH3,
SQL;sum(if(MONTH(invcard.DATEDOC)=4,invcard.SALEPURAMT,0)) as MTH4,
SQL;sum(if(MONTH(invcard.DATEDOC)=5,invcard.SALEPURAMT,0)) as MTH5,
SQL;sum(if(MONTH(invcard.DATEDOC)=6,invcard.SALEPURAMT,0)) as MTH6,
SQL;sum(if(MONTH(invcard.DATEDOC)=7,invcard.SALEPURAMT,0)) as MTH7,
SQL;sum(if(MONTH(invcard.DATEDOC)=8,invcard.SALEPURAMT,0)) as MTH8,
SQL;sum(if(MONTH(invcard.DATEDOC)=9,invcard.SALEPURAMT,0)) as MTH9,
SQL;sum(if(MONTH(invcard.DATEDOC)=10,invcard.SALEPURAMT,0)) as MTH10,
SQL;sum(if(MONTH(invcard.DATEDOC)=11,invcard.SALEPURAMT,0)) as MTH11,
SQL;sum(if(MONTH(invcard.DATEDOC)=12,invcard.SALEPURAMT,0)) as MTH12
SQL;from invcard 
SQL;left join apmst on invcard.ACCID = apmst.ACCID
SQL;where (left(invcard.DOCNO,2) = "RC" or left(invcard.DOCNO,2) = "RO")
SQL;group by 1,2
SQL;order by invcard.ACCID, apmst.XCOMP
CONDITION;ตั้งแต่รหัสเจ้าหนี้~INVCARD.ACCID~Chr~2~SELECT ACCID FROM APMST ~AP
CONDITION;ตั้งแต่วันที่~INVCARD.DATEDOC~Date~2~~
