金蝶云星空查询包含未过账的科目余额表
select a.FACCOUNTID, FBEGINBALANCE,FBEGINBALANCEFOR,FDC,b.FNUMBER,FYTDDEBIT,FYTDCREDIT, isnull(x.FCREDIT,0)FCREDIT,isnull(x.FDEBIT,0) FDEBIT,
case when FDC='-1' then -FBEGINBALANCE-isnull(x.FDEBIT,0)+isnull(x.FCREDIT,0) else FBEGINBALANCE+isnull(x.FDEBIT,0)-isnull(x.FCREDIT,0) end FENDAMOUT,
FYTDCREDIT+isnull(x.FCREDIT,0) FALLCREDIT ,FYTDDEBIT+isnull(x.FDEBIT,0) FALLDEBIT
--into tempgl
from T_GL_Balance a inner join T_BD_ACCOUNT b on a.FACCOUNTID=b.FACCTID
left join ( select b1.fnumber, sum(FDEBIT) FDEBIT , sum(FCREDIT) FCREDIT from T_GL_VOUCHER a inner join T_GL_VOUCHERENTRY b on a.FVOUCHERID=b.FVOUCHERID
inner join T_BD_ACCOUNT b1 on b.FACCOUNTID=b1.FACCTID
where fyear='2023' and FPERIOD='1' and a.FACCOUNTBOOKID='108096' and FISADJUSTVOUCHER='0' and FCURRENCYID='1' and a.FDOCUMENTSTATUS!='Z' group by fnumber) x on b.FNUMBER=x.FNUMBER
where FYEAR='2023' and FPERIOD='1' and FACCOUNTBOOKID='108096' and FCURRENCYID=1 and FDETAILID=0