REPORTFORM;ST5.frf
TITLE;สินค้าคงเหลือ แสดงที่เก็บ ตามรหัสสินค้า
SQL;select invcard.ID, invmst.XDESC, sum(invcard.REPBAL) as XBAL,
SQL;invmst.UNIT, sum(invcard.COSTREPBAL) as XCOSTBAL, 
SQL;invcard.LOCID, loca.LOCDESC, invshelf.shelf
SQL;from invcard 
SQL;left join invmst on invcard.ID = invmst.ID 
SQL;left join loca on invcard.LOCID = loca.LOCID
SQL;left join invshelf on ( invcard.id = invshelf.id and invcard.locid = invshelf.locid)
SQL;where ( invmst.xgroup = '01' or invmst.xgroup = '02' )
SQL;group by invcard.ID, invmst.XDESC, invcard.LOCID, loca.LOCDESC, invmst.UNIT, invshelf.shelf
SQL;order by invcard.LOCID,invcard.ID, invmst.XDESC
CONDITION;ตั้งแต่รหัสคลัง~INVCARD.LOCID~Chr~2~SELECT LOCID FROM LOCA~LOC
CONDITION;ตั้งแต่รหัสสินค้า~INVCARD.ID~Chr~2~SELECT ID FROM INVMST ~INV
CONDITION;สิ้นสุด ณ วันที่~INVCARD.DATEDOC~Date~1~<=~
EXCELSQL;select invcard.LOCID AS "รหัสคลังสินค้า", loca.LOCDESC AS "รายละเอียดคลังสินค้า", invcard.ID AS "รหัสสินค้า", invmst.XDESC AS "รายละเอียดสินค้า",
EXCELSQL;sum(invcard.REPBAL) AS "จำนวน", invmst.UNIT AS "หน่วย", sum(invcard.COSTREPBAL)  AS "มูลค่า",  sum(invcard.COSTREPBAL)/SUM(invcard.REPBAL) AS "ทุน/หน่วย"  ,
EXCELSQL;shelf
EXCELSQL;from invcard 
EXCELSQL;left join invmst on invcard.ID = invmst.ID 
EXCELSQL;left join loca on invcard.LOCID = loca.LOCID
EXCELSQL;left join invshelf on invcard.id = invshelf.id and invcard.locid = invshelf.locid
EXCELSQL;group by invcard.LOCID, loca.LOCDESC,invcard.ID, invmst.XDESC,  invmst.UNIT, invshelf.shelf
EXCELSQL;order by invcard.LOCID,invcard.ID, invmst.XDESC
