REPORTFORM;SA08_1.frf
TITLE;วิเคราะห์ขาย ตามยอดสินค้า วันที่ แสดงหน่วยหลัก
SQL;SELECT
SQL;INVCARD.ID,
SQL;INVMST.XDESC,
SQL;INVMST.UNIT,
SQL;SUM(IF(LEFT(TRTYPE,2)="02",INVCARD.mquan,(INVCARD.mquan * -1))) AS SALEQTY,
SQL;SUM(INVCARD.SALEPURAMT) AS SALEAMT
SQL;FROM INVCARD 
SQL;LEFT JOIN INVMST ON INVCARD.ID = INVMST.ID
SQL;LEFT JOIN ARMST ON INVCARD.ACCID = ARMST.ACCID
SQL;WHERE (LEFT(INVCARD.DOCNO,2) = "IV" OR LEFT(INVCARD.DOCNO,2) = "RI")
SQL;GROUP BY 1,2,3
SQL;ORDER BY 1,2,3
CONDITION;ตั้งแต่วันที่~INVCARD.DATEDOC~Date~2~SELECT DATEDOC FROM INVCARD~
CONDITION;ตั้งแต่รหัสสินค้า~INVCARD.ID~Chr~2~SELECT ID FROM INVMST~INV
EXCELSQL;SELECT
EXCELSQL;INVCARD.ID AS "รหัสสินค้า",
EXCELSQL;INVMST.XDESC AS "รายละเอียดสินค้า",
EXCELSQL;INVMST.UNIT AS "หน่วยนับ",
EXCELSQL;SUM(IF(LEFT(TRTYPE,2)="02",INVCARD.mquan,(INVCARD.mquan * -1))) AS SALEQTY,
EXCELSQL;SUM(INVCARD.SALEPURAMT) AS SALEAMT
EXCELSQL;FROM INVCARD 
EXCELSQL;LEFT JOIN INVMST ON INVCARD.ID = INVMST.ID
EXCELSQL;LEFT JOIN ARMST ON INVCARD.ACCID = ARMST.ACCID
EXCELSQL;WHERE (LEFT(INVCARD.DOCNO,2) = "IV" OR LEFT(INVCARD.DOCNO,2) = "RI")
EXCELSQL;GROUP BY 1,2,3
EXCELSQL;ORDER BY 1,2,3
USECROSSTAB;N
CROSSTABFRF;N
CROSSTABHEAD;
CROSSTABFIELD;
