REPORTFORM;GLCARD1.frf
TITLE;รายงานบัญชีแยกประเภท
SQL;drop table if exists _glcard&
SQL;
SQL;create table _glcard
SQL;select gltr.GLID, glmst.GLDESC,gltr.DATEDOC, gltr.DOCNO, gltrhd.XREMLINE, glmst.GLTYPE, gltr.DEBIT, gltr.CREDIT,
SQL;0000000000.00 as nbal , 1 as line, if(instr('AEC',left(glmst.GLTYPE,1)) > 0 , "D","C") as nature
SQL;from gltr inner join gltrhd on gltr.DOCNO = gltrhd.DOCNO
SQL;inner join glmst on gltr.GLID = glmst.GLID
SQL;where gltr.glid >= :m21 and gltr.glid <= :m22
SQL;and gltr.datedoc >= :m11 and gltr.datedoc <= :m12
SQL;&
SQL;
SQL;insert into _glcard
SQL;select gltr.GLID, glmst.GLDESC,'', 'ยอดยกมา', '', glmst.GLTYPE, 0, 0,
SQL;sum(if(instr('AEC',left(glmst.GLTYPE,1)) > 0,gltr.DEBIT - gltr.CREDIT,gltr.CREDIT - gltr.DEBIT)) as nbal , 0 as line, if(instr('AEC',left(glmst.GLTYPE,1)) > 0 , "D","C") as nature
SQL;from gltr inner join gltrhd on gltr.DOCNO = gltrhd.DOCNO
SQL;inner join glmst on gltr.GLID = glmst.GLID
SQL;where gltr.glid >= :m21 and gltr.glid <= :m22
SQL;and gltr.datedoc < :m11 
SQL;group by gltr.GLID, glmst.GLDESC&
SQL;
SQL;select * from _glcard order by glid,line, datedoc
CONDITION;ตั้งแต่วันที่~DATEDOC~Date~2~~
CONDITION;ตั้งแต่รหัสผังบัญชี~GLID~Chr~2~SELECT GLID FROM GLMST~GLID
