REPORTFORM;SA05.frf
TITLE;วิเคราะห์ขายตามยอดขายลูกค้าของพนักงาน
SQL;SELECT
SQL;INVCARD.SALEID,
SQL;SALEMST.SNAME,
SQL;INVCARD.ACCID,
SQL;ARMST.XCOMP,
SQL;SUM(INVCARD.SALEPURAMT) AS SALEAMT,
SQL;SUM(INVCARD.SALEPURQTY) AS SALEQTY
SQL;FROM INVCARD 
SQL;LEFT JOIN SALEMST ON INVCARD.SALEID = SALEMST.SID
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.SALEID, SALEAMT DESC
CONDITION;ตั้งแต่วันที่~INVCARD.DATEDOC~Date~2~SELECT DATEDOC FROM INVCARD~
CONDITION;ตั้งแต่รหัสพนักงาน~INVCARD.SALEID~Chr~2~SELECT SALEID FROM ARCARD~SALE
EXCELSQL;SELECT
EXCELSQL;INVCARD.SALEID AS "รหัสพนักงาน",
EXCELSQL;SALEMST.SNAME AS "ชื่อ สกุลพนักงาน",
EXCELSQL;INVCARD.ACCID AS "รหัสลูกค้า",
EXCELSQL;ARMST.XCOMP AS "รายละเอียดลูกค้า",
EXCELSQL;SUM(INVCARD.SALEPURAMT) AS SALEAMT,
EXCELSQL;SUM(INVCARD.SALEPURQTY) AS SALEQTY
EXCELSQL;FROM INVCARD 
EXCELSQL;LEFT JOIN SALEMST ON INVCARD.SALEID = SALEMST.SID
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.SALEID, SALEAMT DESC
