REPORTFORM;RF6.frf
TITLE;รายงานประเมินการใช้วัตถุดิบจาก รับสินค้าจากผลิต
SQL;drop table if exists _RF&
SQL;create table _RF
SQL;select invcard.ID, SUM(invcard.MQUAN) AS MQ
SQL;from invcard 
SQL;where left(invcard.DOCNO,2) = 'RF' and 
SQL;invcard.datedoc >= :m11 and invcard.datedoc <= :m12
SQL;GROUP BY 1&
SQL;
SQL;drop table if exists _RAWMAT&
SQL;create table _RAWMAT
SQL;select invfor.idraw as id, invmst.XDESC,
SQL;(invfor.forqty * _RF.MQ) AS QTYUSE, invmst.UNIT
SQL;from invfor inner join _RF on invfor.id = _RF.id
SQL;inner join invmst on invfor.idraw  = invmst.ID&
SQL;
SQL;select id,xdesc,sum(QTYUSE) as QTY,unit from _RAWMAT
SQL;group by id,xdesc,unit
CONDITION;ตั้งแต่วันที่~INVCARD.DATEDOC~Date~2~~
EXCELSQL;drop table if exists _RF&
EXCELSQL;create table _RF
EXCELSQL;select invcard.ID, SUM(invcard.MQUAN) AS MQ
EXCELSQL;from invcard 
EXCELSQL;where left(invcard.DOCNO,2) = 'RF' and 
EXCELSQL;invcard.datedoc >= :m11 and invcard.datedoc <= :m12
EXCELSQL;GROUP BY 1&
EXCELSQL;
EXCELSQL;drop table if exists _RAWMAT&
EXCELSQL;create table _RAWMAT
EXCELSQL;select invfor.idraw as id, invmst.XDESC,
EXCELSQL;(invfor.forqty * _RF.MQ) AS QTYUSE, invmst.UNIT
EXCELSQL;from invfor inner join _RF on invfor.id = _RF.id
EXCELSQL;inner join invmst on invfor.idraw  = invmst.ID&
EXCELSQL;
EXCELSQL;select id,xdesc,sum(QTYUSE) as QTY,unit from _RAWMAT
EXCELSQL;group by id,xdesc,unit
EXCELSQL;
