REPORTFORM;SA03.frf
TITLE;วิเคราะห์ขายตามยอดขาย ลูกค้า
SQL;SELECT
SQL;INVCARD.ACCID,
SQL;ARMST.XCOMP,
SQL;SUM(INVCARD.SALEPURAMT) AS SALEAMT,
SQL;SUM(INVCARD.SALEPURQTY) AS SALEQTY
SQL;FROM INVCARD LEFT JOIN ARMST
SQL;ON INVCARD.ACCID = ARMST.ACCID
SQL;WHERE (LEFT(INVCARD.DOCNO,2) = "IV" OR LEFT(INVCARD.DOCNO,2) = "RI")
SQL;GROUP BY 1,2
SQL;ORDER BY 3 DESC
CONDITION;ตั้งแต่วันที่~INVCARD.DATEDOC~Date~2~SELECT DATEDOC FROM INVCARD~
CONDITION;ตั้งแต่รหัสลูกค้า ~INVCARD.ACCID~Chr~2~SELECT ACCID FROM ARMST ~AR
EXCELSQL;SELECT
EXCELSQL;INVCARD.ACCID AS "รหัสลูกค้า",
EXCELSQL;ARMST.XCOMP AS "รายละเอียดลูกค้า",
EXCELSQL;SUM(INVCARD.SALEPURAMT) AS "ยอดขาย",
EXCELSQL;SUM(INVCARD.SALEPURQTY) AS "จำนวนขาย"
EXCELSQL;FROM INVCARD LEFT JOIN ARMST
EXCELSQL;ON INVCARD.ACCID = ARMST.ACCID
EXCELSQL;WHERE (LEFT(INVCARD.DOCNO,2) = "IV" OR LEFT(INVCARD.DOCNO,2) = "RI")
EXCELSQL;GROUP BY 1,2
EXCELSQL;ORDER BY 3 DESC
