REPORTFORM;PU7.frf
TITLE;รายงานแสดงจำนวนซื้อทั้งปี ตามรหัสสินค้า
SQL;select invcard.ID, invmst.XDESC,sum(invcard.SALEPURQTY)as XTOTAL,
SQL;sum(if(MONTH(invcard.DATEDOC)=1,invcard.SALEPURQTY,0)) as MTH1,
SQL;sum(if(MONTH(invcard.DATEDOC)=2,invcard.SALEPURQTY,0)) as MTH2,
SQL;sum(if(MONTH(invcard.DATEDOC)=3,invcard.SALEPURQTY,0)) as MTH3,
SQL;sum(if(MONTH(invcard.DATEDOC)=4,invcard.SALEPURQTY,0)) as MTH4,
SQL;sum(if(MONTH(invcard.DATEDOC)=5,invcard.SALEPURQTY,0)) as MTH5,
SQL;sum(if(MONTH(invcard.DATEDOC)=6,invcard.SALEPURQTY,0)) as MTH6,
SQL;sum(if(MONTH(invcard.DATEDOC)=7,invcard.SALEPURQTY,0)) as MTH7,
SQL;sum(if(MONTH(invcard.DATEDOC)=8,invcard.SALEPURQTY,0)) as MTH8,
SQL;sum(if(MONTH(invcard.DATEDOC)=9,invcard.SALEPURQTY,0)) as MTH9,
SQL;sum(if(MONTH(invcard.DATEDOC)=10,invcard.SALEPURQTY,0)) as MTH10,
SQL;sum(if(MONTH(invcard.DATEDOC)=11,invcard.SALEPURQTY,0)) as MTH11,
SQL;sum(if(MONTH(invcard.DATEDOC)=12,invcard.SALEPURQTY,0)) as MTH12
SQL;from invcard 
SQL;left join invmst on invcard.ID = invmst.ID
SQL;where (left(invcard.DOCNO,2) = "RC" or left(invcard.DOCNO,2) = "RO")
SQL;group by 1
SQL;order by invcard.ID, invcard.XDESC
CONDITION;ตั้งแต่รหัสสินค้า~INVCARD.ID~Chr~2~SELECT ID FROM INVMST ~INV
CONDITION;ตั้งแต่วันที่~INVCARD.DATEDOC~Date~2~~
USECROSSTAB;N
CROSSTABFRF;N
CROSSTABHEAD;
CROSSTABFIELD;
