REPORTFORM;DP2_1.frf
TITLE;รายงานการลดหนี้เจ้าหนี้ ตามรหัสเจ้าหนี้ วันที่
SQL;drop table if exists _APDP&
SQL;
SQL;create table  _APDP
SQL;select apcard.DOCNO, apcard.DATEDOC, apcard.REFNO,
SQL;apcard.ACCID, apmst.XCOMP, 0000000000.00 as DEBY, apcard.AMOUNT_D, 0000000000.00 as bal, apcard.DPTID,
SQL;apcard.TAXNO
SQL;from apcard
SQL;left join apmst on apcard.ACCID = apmst.ACCID
SQL;where left(apcard.TRTYPE,2)= "DP"
SQL;order by apcard.ACCID, apcard.DOCNO, apcard.DATEDOC&
SQL;
SQL;drop table if exists _APDP1&
SQL;
SQL;create table  _APDP1
SQL;select apcard.DOCNO,  apcard.AMOUNT_D
SQL;from apcard
SQL;where left(apcard.TRTYPE,2)= "AP"&
SQL;
SQL;update _APDP left join _APDP1 on _APDP.REFNO = _APDP1.DOCNO
SQL;set _APDP.DEBY = _APDP1.AMOUNT_D& 
SQL;
SQL;update _APDP set _APDP.bal = _APDP.DEBY - _APDP.AMOUNT_D&
SQL;
SQL;select * from _APDP
CONDITION;ตั้งแต่รหัสเจ้าหนี้~APCARD.ACCID ~Chr~2~SELECT ACCID FROM APMST~AP
CONDITION;ตั้งแต่วันที่~APCARD.DATEDOC ~Date~2~~
EXCELSQL;drop table if exists _APDP&
EXCELSQL;
EXCELSQL;create table  _APDP
EXCELSQL;select apcard.DOCNO, apcard.DATEDOC, apcard.REFNO,
EXCELSQL;apcard.ACCID, apmst.XCOMP, 0000000000.00 as DEBY, apcard.AMOUNT_D, 0000000000.00 as bal, apcard.DPTID,
EXCELSQL;apcard.TAXNO
EXCELSQL;from apcard
EXCELSQL;left join apmst on apcard.ACCID = apmst.ACCID
EXCELSQL;where left(apcard.TRTYPE,2)= "DP"
EXCELSQL;order by apcard.ACCID, apcard.DOCNO, apcard.DATEDOC&
EXCELSQL;
EXCELSQL;drop table if exists _APDP1&
EXCELSQL;
EXCELSQL;create table  _APDP1
EXCELSQL;select apcard.DOCNO,  apcard.AMOUNT_D
EXCELSQL;from apcard
EXCELSQL;where left(apcard.TRTYPE,2)= "AP"&
EXCELSQL;
EXCELSQL;update _APDP left join _APDP1 on _APDP.REFNO = _APDP1.DOCNO
EXCELSQL;set _APDP.DEBY = _APDP1.AMOUNT_D& 
EXCELSQL;
EXCELSQL;update _APDP set _APDP.bal = _APDP.DEBY - _APDP.AMOUNT_D&
EXCELSQL;
EXCELSQL;select docno as "เลขที่เอกสาร",
EXCELSQL;datedoc as "วันที่เอกสาร",
EXCELSQL;refno as "เลขที่อ้างอิง",
EXCELSQL;accid as "รหัสลูกค้า",
EXCELSQL;xcomp as "ชื่อ-บริษัทลูกค้า",
EXCELSQL;deby as "ยอดตั้งหนี้",
EXCELSQL;amount_d as "ยอดส่วนลด",
EXCELSQL;bal as "ยอดคงเหลือ",
EXCELSQL;dptid as "รหัสแผนก",
EXCELSQL;taxno as "เลขที่ใบกำกับภาษี" from _APDP
