REPORTFORM;STB1.frf
TITLE;รายงานสินค้าคงเหลือตาม BARCODE
SQL;SELECT UNPR.ID, UNPR.UNIT,UNPR.LINE,
SQL;SUM(INVCARD.REPBAL) as NBAL , SUM(INVCARD.COSTREPBAL) AS XCOST,
SQL;INVMST.XDESC, INVCARD.LOCID, UNPR.barcode
SQL;FROM UNPR 
SQL;LEFT JOIN INVCARD ON UNPR.ID = INVCARD.ID
SQL;LEFT JOIN INVMST ON UNPR.ID = INVMST.ID AND UNPR.UNIT = INVMST.UNIT
SQL;where ( INVMST.xgroup = '01' or INVMST.xgroup = '02' )
SQL;GROUP BY UNPR.ID, INVMST.XDESC
SQL;ORDER BY UNPR.ID
CONDITION;ตั้งแต่รหัสสินค้า~UNPR.ID~Chr~2~SELECT ID FROM INVMST~INV
CONDITION;สิ้นสุด ณ วันที่~INVCARD.DATEDOC~Date~1~<=~
EXCELSQL;SELECT UNPR.ID AS "รหัสสินค้า", UNPR.barcode AS "รหัสBARCODE", INVMST.XDESC AS "รายละเอียดสินค้า",UNPR.UNIT AS "หน่วยนับ",
EXCELSQL;SUM(INVCARD.REPBAL) AS "จำนวน", INVCARD.LOCID AS "รหัสคลัง"
EXCELSQL;FROM UNPR 
EXCELSQL;LEFT JOIN INVCARD ON UNPR.ID = INVCARD.ID
EXCELSQL;LEFT JOIN INVMST ON UNPR.ID = INVMST.ID AND UNPR.UNIT = INVMST.UNIT
EXCELSQL;where ( INVMST.xgroup = '01' or INVMST.xgroup = '02' )
EXCELSQL;GROUP BY UNPR.ID, INVMST.XDESC
EXCELSQL;ORDER BY UNPR.ID
