科目余额表sql原创
131人赞赏了该文章
2,516次浏览
编辑于2023年11月24日 13:47:52
之前因客户需求,需要从科目余额表取数出来处理成新的报表,但是sql直接抓取科目余额表与系统前台数据对不上,经查找测试,因为勾选了包含未过账凭证,而科目余额表取出来是已过账的,所以我们需要关联凭证取出未过账的数据(核算维度按需关联即可)
SELECT TBAL.FNAME 账簿, TBCL.FNAME 币别, TGB.FYear 年, TGB.FPeriod 期, -- TGB.FAdjustPeriod 调整期, 1 是否过账0未过账1已过账, TGB.FDebit 借方本位币金额, TBACL.FNAME 科目名称, TBF.FFLEX9 FFLEX9内码, TBEL.FNAME 费用项目名称, TBF.FFLEX5 FFLEX5内码, TBDL.FNAME 部门名称, TBF.FF100003 FF100003内码, TBOEL.FNAME 业务组名称, TBF.FFLEX6 FFLEX6内码, TBCTL.FNAME 客户名称 FROM T_GL_BALANCE TGB--科目余额表 LEFT JOIN T_BD_ACCOUNTBOOK TBA ON TGB.FACCOUNTBOOKID = TBA.FBOOKID --账簿 LEFT JOIN T_BD_ACCOUNTBOOK_L TBAL ON TBA.FBOOKID = TBAL.FBOOKID AND TBAL.FLOCALEID = '2052' --账簿多语言 LEFT JOIN T_BD_CURRENCY TBC ON TGB.FCurrencyID = TBC.FCURRENCYID --币别 LEFT JOIN T_BD_CURRENCY_L TBCL ON TBC.FCURRENCYID = TBCL.FCURRENCYID AND TBCL.FLOCALEID = '2052' --币别多语言 LEFT JOIN T_BD_ACCOUNT TBAC ON TGB.FAccountID = TBAC.FACCTID --科目 LEFT JOIN T_BD_ACCOUNT_L TBACL ON TBAC.FACCTID = TBACL.FACCTID AND TBACL.FLOCALEID = '2052' --科目多语言 LEFT JOIN T_BD_FLEXITEMDETAILV TBF ON TGB.FDetailID = TBF.FID --核算维度数据表 LEFT JOIN T_BD_EXPENSE TBE ON TBF.FFLEX9 = TBE.FEXPID --费用项目 LEFT JOIN T_BD_EXPENSE_L TBEL ON TBE.FEXPID = TBEL.FEXPID AND TBEL.FLOCALEID = '2052' --费用项目多语言 LEFT JOIN T_BD_DEPARTMENT TBD ON TBF.FFLEX5 = TBD.FDEPTID --部门 LEFT JOIN T_BD_DEPARTMENT_L TBDL ON TBD.FDEPTID = TBDL.FDEPTID AND TBDL.FLOCALEID = '2052' --部门多语言 LEFT JOIN T_BD_OPERATORGROUPENTRY_L TBOEL ON TBF.FF100003 = TBOEL.FEntryId AND TBOEL.FLocaleId = '2052' --业务组分录多语言 LEFT JOIN T_BD_CUSTOMER TBCT ON TBF.FFLEX6 = TBCT.FCUSTID --客户 LEFT JOIN T_BD_CUSTOMER_L TBCTL ON TBCT.FCUSTID = TBCTL.FCUSTID AND TBCTL.FLocaleId = '2052' --客户多语言 UNION ALL SELECT TBAL.FNAME 账簿, TBCL.FNAME 币别, TGV.FYEAR 年, TGV.FPERIOD 期, TGV.FPOSTED 是否过账0未过账1已过账, TGVE.fdebit 借方本位币金额, TBACL.FNAME 科目名称, TBF.FFLEX9 FFLEX9内码, TBEL.FNAME 费用项目名称, TBF.FFLEX5 FFLEX5内码, TBDL.FNAME 部门名称, TBF.FF100003 FF100003内码, TBOEL.FNAME 业务组名称, TBF.FFLEX6 FFLEX6内码, TBCTL.FNAME 客户名称 FROM T_GL_VOUCHER TGV --凭证 LEFT JOIN T_BD_ACCOUNTBOOK TBA ON TGV.FACCOUNTBOOKID = TBA.FBOOKID --账簿 LEFT JOIN T_BD_ACCOUNTBOOK_L TBAL ON TBA.FBOOKID = TBAL.FBOOKID AND TBAL.FLOCALEID = '2052' --账簿多语言 LEFT JOIN T_GL_VOUCHERENTRY TGVE ON TGV.FVoucherID = TGVE.FVoucherID --凭证分录 LEFT JOIN T_BD_ACCOUNT TBAC ON TGVE.FAccountID = TBAC.FACCTID --科目 LEFT JOIN T_BD_ACCOUNT_L TBACL ON TBAC.FACCTID = TBACL.FACCTID AND TBACL.FLOCALEID = '2052' --科目多语言 LEFT JOIN T_BD_CURRENCY TBC ON TGVE.FCURRENCYID = TBC.FCURRENCYID --币别 LEFT JOIN T_BD_CURRENCY_L TBCL ON TBC.FCURRENCYID = TBCL.FCURRENCYID AND TBCL.FLOCALEID = '2052' --币别多语言 LEFT JOIN T_BD_FLEXITEMDETAILV TBF ON TGVE.FDetailID = TBF.FID --核算维度数据表 LEFT JOIN T_BD_EXPENSE TBE ON TBF.FFLEX9 = TBE.FEXPID --费用项目 LEFT JOIN T_BD_EXPENSE_L TBEL ON TBE.FEXPID = TBEL.FEXPID AND TBEL.FLOCALEID = '2052' --费用项目多语言 LEFT JOIN T_BD_DEPARTMENT TBD ON TBF.FFLEX5 = TBD.FDEPTID --部门 LEFT JOIN T_BD_DEPARTMENT_L TBDL ON TBD.FDEPTID = TBDL.FDEPTID AND TBDL.FLOCALEID = '2052' --部门多语言 LEFT JOIN T_BD_OPERATORGROUPENTRY_L TBOEL ON TBF.FF100003 = TBOEL.FEntryId AND TBOEL.FLocaleId = '2052' --业务组分录多语言 LEFT JOIN T_BD_CUSTOMER TBCT ON TBF.FFLEX6 = TBCT.FCUSTID --客户 LEFT JOIN T_BD_CUSTOMER_L TBCTL ON TBCT.FCUSTID = TBCTL.FCUSTID AND TBCTL.FLocaleId = '2052' --客户多语言 WHERE TGV.FPOSTED = '0' --是否过账
赞 131
131人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读