REPORTFORM;AR_12_1.frf
TITLE;ยอดหนี้คงเหลือ เรียงตามรหัสลูกค้า (แบบที่ 2)
SQL;SELECT ARCARD.DOCNO, ARCARD.REFNO,ARCARD.DATEDOC,ARCARD.ACCID,ARMST.XCOMP,
SQL;ARCARD.CUS_PO, ARCARD.DISCD , ARCARD.VATAMT, ARCARD.DATEINV, ARCARD.AMOUNT_D,
SQL;ARCARD.BILLDOC, ARCARD.DUEDATE, ARCARD.ADVAMT, BILLHD.BILLDATE,ARCARD.INVAMT, ARCARD.AMOUNT_D - ARCARD.RECAMT as NAL,
SQL;IF(LEFT(TRTYPE,2)="AR",REPBAL,0) AS mDEBT,
SQL;IF(LEFT(TRTYPE,2)="BR",REPBAL,0) AS mREC,
SQL;IF(LEFT(TRTYPE,2)="DR",REPBAL,0) AS mDISC
SQL;FROM ARCARD LEFT JOIN ARMST ON ARCARD.ACCID = ARMST.ACCID
SQL;LEFT JOIN BILLHD ON ARCARD.ACCID = BILLHD.ACCID
SQL;WHERE ARCARD.REPBAL <> 0
SQL;ORDER BY ARCARD.ACCID, ARCARD.DATEDOC, ARCARD.DOCNO
CONDITION;ตั้งแต่รหัสลูกค้า ~ARCARD.ACCID~Chr~2~SELECT ACCID FROM ARMST ~AR
CONDITION;ตั้งแต่วันที่~ARCARD.DATEDOC~Date~2~~
