REPORTFORM;IVC2.frf
TITLE;รายงานต้นทุนสินค้าแยกคลัง
SQL;SELECT INVCARD.ID, INVMST.XDESC, INVMST.UNIT, SUM(INVCARD.COSTREPBAL) AS XCOST, 
SQL;SUM(REPBAL) AS NBAL,INVCARD.LOCID,LOCA.LOCDESC
SQL;FROM INVCARD
SQL;LEFT JOIN INVMST ON INVCARD.ID = INVMST.ID
SQL;LEFT JOIN LOCA ON INVCARD.LOCID = LOCA.LOCID
SQL;WHERE (INVMST.XGROUP="01" OR INVMST.XGROUP="02")
SQL;GROUP BY INVCARD.ID, INVMST.XDESC, INVMST.UNIT,INVCARD.LOCID, LOCA.LOCDESC
SQL;ORDER BY INVCARD.LOCID,INVCARD.ID
CONDITION;ตั้งแต่รหัสสินค้า~INVCARD.ID~Chr~2~SELECT ID FROM INVMST~INV
CONDITION;ตั้งแต่รหัสคลังสินค้า~INVCARD.LOCID~Chr~2~SELECT LOCID FROM LOCA~LOC
CONDITION;สิ้นสุด ณ วันที่~INVCARD.DATEDOC~Date~1~<=~
CONDITION;เงื่อนไข~~TextFile~~STKBAL2.TXT~
EXCELSQL;SELECT INVCARD.ID, INVMST.XDESC, INVMST.UNIT, SUM(INVCARD.COSTREPBAL) AS XCOST, 
EXCELSQL;SUM(REPBAL) AS "ยอดคงเหลือ",
EXCELSQL;((SUM(INVCARD.COSTREPBAL))/(SUM(REPBAL))) AS "ต้นทุน/หน่วย",
EXCELSQL;((SUM(INVCARD.COSTREPBAL))/(SUM(REPBAL)))*(SUM(REPBAL)) AS "มูลค่าปลายงวด",
EXCELSQL;INVCARD.LOCID,LOCA.LOCDESC
EXCELSQL;FROM INVCARD
EXCELSQL;LEFT JOIN INVMST ON INVCARD.ID = INVMST.ID
EXCELSQL;LEFT JOIN LOCA ON INVCARD.LOCID = LOCA.LOCID
EXCELSQL;WHERE (INVMST.XGROUP="01" OR INVMST.XGROUP="02")
EXCELSQL;GROUP BY INVCARD.ID, INVMST.XDESC, INVMST.UNIT,INVCARD.LOCID, LOCA.LOCDESC
EXCELSQL;ORDER BY INVCARD.LOCID,INVCARD.ID
USECROSSTAB;N
CROSSTABFRF;N
CROSSTABHEAD;
CROSSTABFIELD;
