REPORTFORM;SA08.frf
TITLE;วิเคราะห์ขาย ตามยอดสินค้า ของลูกค้า
SQL;SELECT
SQL;INVCARD.ACCID,
SQL;ARMST.XCOMP,
SQL;INVCARD.ID,
SQL;INVMST.XDESC,
SQL;INVMST.UNIT,
SQL;SUM(INVCARD.SALEPURQTY) 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,4
SQL;ORDER BY INVCARD.ACCID, SALEAMT DESC
CONDITION;ตั้งแต่วันที่~INVCARD.DATEDOC~Date~2~SELECT DATEDOC FROM INVCARD~
CONDITION;ตั้งแต่รหัสลูกค้า~INVCARD.ACCID~Chr~2~SELECT ACCID FROM ARMST~AR
CONDITION;ตั้งแต่รหัสสินค้า~INVCARD.ID~Chr~2~SELECT ID FROM INVMST~INV
EXCELSQL;SELECT
EXCELSQL;INVCARD.ACCID AS "รหัสลูกค้า",
EXCELSQL;ARMST.XCOMP AS "รายละเอียดลูกค้า",
EXCELSQL;INVCARD.ID AS "รหัสสินค้า",
EXCELSQL;INVMST.XDESC AS "รายละเอียดสินค้า",
EXCELSQL;INVMST.UNIT AS "หน่วยนับ",
EXCELSQL;SUM(INVCARD.SALEPURQTY) 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,4
EXCELSQL;ORDER BY INVCARD.ACCID, SALEAMT DESC
