TITLE;แสดงกำไร/ขาดทุน ตามวันที่
SQL;drop table if exists _pfgrp&
SQL;create table _pfgrp
SQL;select   "รายได้" AS  xdesc,sum(gltr.credit-gltr.debit) as mVALUE,1 AS Mflag,1 as mline
SQL;from gltr inner join glmst on gltr.glid = glmst.glid
SQL;where gltr.datedoc >= :m11 and gltr.datedoc <= :m12
SQL;and left(glmst.gltype,1) = "R"&
SQL;
SQL;insert into _pfgrp
SQL;select   "ต้นทุน" AS  xdesc,sum(gltr.debit-gltr.credit) as mVALUE,-1 AS Mflag,2 as mline
SQL;from gltr inner join glmst on gltr.glid = glmst.glid
SQL;where gltr.datedoc >= :m11 and gltr.datedoc <= :m12
SQL;and left(glmst.gltype,1) = "C"&
SQL;
SQL;insert into _pfgrp
SQL;select   "ค่าใช้จ่าย" AS  xdesc,sum(gltr.debit-gltr.credit) as mVALUE,-1 AS Mflag,3 as mline
SQL;from gltr inner join glmst on gltr.glid = glmst.glid
SQL;where gltr.datedoc >= :m11 and gltr.datedoc <= :m12
SQL;and left(glmst.gltype,1) = "E"&
SQL;
SQL;drop table if exists _pfgrp2&
SQL;create table _pfgrp2
SQL;select "กำไร/ขาดทุน" as xdesc,sum(mvalue * Mflag) as mvalue,0 as mflag,4 as mline
SQL;from _pfgrp&
SQL;
SQL;insert into _pfgrp
SQL;select * from _pfgrp2&
SQL;
SQL;select * from _pfgrp order by mline
CONDITION;ตั้งแต่วันที่~GLTR.DATEDOC~Date~2~~
SERIES;1~XDESC~MVALUE~
