电脑桌面
添加蚂蚁七词文库到电脑桌面
安装后可以在桌面快捷访问

总账常用的查询SQL

来源:金蝶云社区作者:金蝶2024-09-223

总账常用的查询SQL

1、凭证

--查询某张凭证记录

select v.* from t_gl_voucher v 

inner join t_bd_period p on p.fid=v.fperiodid 

inner join T_BD_VoucherTypes vt on v.FVoucherTypeID=vt.fid

inner join t_org_company c on c.fid=v.fcompanyid 

where p.fnumber='期间编码'and c.fnumber='公司编码'and vt.fnumber='凭证类型编码' and v.fnumber='凭证号'


--查询某张凭证的对应分录记录

select  ve.* from t_gl_voucher v 

inner join t_bd_period p on p.fid=v.fperiodid 

inner join t_org_company c on c.fid=v.fcompanyid

inner join T_BD_VoucherTypes vt on v.FVoucherTypeID=vt.fid

inner join t_gl_voucherentry ve on ve.fbillid=v.fid

inner join t_bd_accountview av on ve.faccountid=av.fid 

where p.fnumber='期间编码'and c.fnumber='公司编码' and vt.fnumber='凭证类型编码' and v.fnumber='凭证号' and  av.fnumber='科目编码'  and ve.fseq='分录号'


--查询某张凭证的辅助账记录

select  vs.* from t_gl_voucher v 

inner join t_bd_period p on p.fid=v.fperiodid 

inner join t_org_company c on c.fid=v.fcompanyid

inner join T_BD_VoucherTypes vt on v.FVoucherTypeID=vt.fid

inner join t_gl_voucherentry ve on ve.fbillid=v.fid

inner join t_bd_accountview av on ve.faccountid=av.fid

inner join t_gl_voucherassistrecord vs on vs.fentryid=ve.fid 

where p.fnumber='期间编码'and c.fnumber='公司编码' and vt.fnumber='凭证类型编码' and v.fnumber='凭证号' and  av.fnumber='科目编码'  and ve.fseq='分录号'


--查询某个成本中心被哪些公司哪些期间的凭证所引用

select   distinct  c.fnumber 公司编码,c.FNAME_L2 公司名称,  p.fnumber 期间编码,vt.fnumber 凭证类型编码,v.fnumber 凭证号
from t_gl_voucher v
inner join t_gl_voucherentry ve on ve.fbillid=v.fid

inner join t_gl_voucherassistrecord vs on vs.fentryid=ve.fid

inner join T_BD_VoucherTypes vt on v.FVoucherTypeID=vt.fid

inner join t_bd_period p on p.fid=v.fperiodid 

inner join t_org_company c on c.fid=v.fcompanyid

inner join  t_bd_assistanthg hg on hg.fid=vs.fassgrpid
inner join T_ORG_CostCenter cc on hg.FCostOrgID=cc.fid

where cc.Fnumber='成本中心编码'


2、现金流量

--查询对应凭证的现金流量记录

select cf.* from t_gl_voucher v

inner join T_BD_VoucherTypes vt on v.FVoucherTypeID=vt.fid

inner join t_bd_period p on p.fid=v.fperiodid 

inner join t_org_company c on c.fid=v.fcompanyid

inner  join  t_gl_cashflowrecord cf on cf.fvoucherid=v.fid 

where p.fnumber='期间编码'and c.fnumber='公司编码' and vt.fnumber='凭证类型编码' and v.fnumber='凭证号'


3、往来核算

--查询凭证的核销记录

select av.* from t_gl_voucher v 

inner join T_BD_VoucherTypes vt on v.FVoucherTypeID=vt.fid

inner join t_gl_voucherentry ve on ve.fbillid=v.fid 

inner join t_gl_voucherassistrecord vs on vs.fentryid=ve.fid 

inner join t_bd_period p on p.fid=v.fperiodid 

inner join t_org_company c on c.fid=v.fcompanyid 

inner join t_gl_acctverify av on av.FVCHASSISTRECORDID=vs.fid 

where p.fnumber='期间编码'and c.fnumber='公司编码' and vt.fnumber='凭证类型编码' and v.fnumber='凭证号' and ve.seq='分录号' and vs.fseq='辅助账行号'


--查询凭证的挂账记录

select ac.* from t_gl_voucher v 

inner join T_BD_VoucherTypes vt on v.FVoucherTypeID=vt.fid

inner join t_gl_voucherentry ve on ve.fbillid=v.fid 

inner join t_gl_voucherassistrecord vs on vs.fentryid=ve.fid 

inner join t_bd_period p on p.fid=v.fperiodid 

inner join t_org_company c on c.fid=v.fcompanyid 

inner join t_gl_acctcussent ac  on ac.FVCHASSISTRECORDID=vs.fid 

where p.fnumber='期间编码'and c.fnumber='公司编码' and vt.fnumber='凭证类型编码' and v.fnumber='凭证号' and ve.seq='分录号' and vs.fseq='辅助账行号'


4、余额表

--查询某个科目某个期间的科目余额记录(以科目余额(包含未过账本位币)为例,其余科目余额表的表名请参考此贴:总账的相关表

select  ab1.* from  t_gl_acc

总账常用的查询SQL

1、凭证--查询某张凭证记录select v.* from t_gl_voucher v inner join t_bd_period p on p.fid=v.fperiodid inner join T_BD_Vo...
点击下载文档文档为doc格式

声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

已经是第一篇
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息
QQ群
  • 答案:my7c点击这里加入QQ群
支持邮箱
微信
  • 微信