REPORTFORM;SA03_K.frf
TITLE;รายงานสรุปการขายลูกค้า เรียงตามยอดขาย
SQL;select arcard.accid,armst.XCOMP, 
SQL;sum(if(left(docno,2)="IV",arcard.INVAMT,arcard.invamt * -1))as invamt, 
SQL;sum(if(left(docno,2)="IV",arcard.VATAMT,arcard.VATAMT * -1))as vatamt 
SQL;from arcard left join armst on arcard.ACCID = armst.ACCID
SQL;where (left(docno,2) = 'IV' or left(docno,2) = 'RI' )
SQL;group by arcard.accid,armst.XCOMP
SQL;order by 3 desc
CONDITION;ตั้งแต่วันที่~ARCARD.DATEDOC~Date~2~~
CONDITION;ตั้งแต่รหัสลูกค้า ~ARCARD.ACCID~Chr~2~SELECT ACCID FROM ARMST ~AR
EXCELSQL;select arcard.accid AS "รหัสลูกค้า",
EXCELSQL;armst.XCOMP AS "ชื่อ - บริษัทลูกค้า", 
EXCELSQL;sum(if(left(docno,2)="IV",arcard.INVAMT,arcard.invamt * -1)) AS "ยอดขาย", 
EXCELSQL;sum(if(left(docno,2)="IV",arcard.VATAMT,arcard.VATAMT * -1)) AS "ภาษีมูลค่าเพิ่ม" 
EXCELSQL;from arcard left join armst on arcard.ACCID = armst.ACCID
EXCELSQL;where (left(docno,2) = 'IV' or left(docno,2) = 'RI' )
EXCELSQL;group by arcard.accid,armst.XCOMP
EXCELSQL;order by 3 desc
