|
发表于 2008-11-12 11:16:26
|
显示全部楼层
本文章已经学习完毕,先总结如下:
1、查询数据库中所有11月份类别为01的凭证
select * from gl_accvouch where iperiod=11 and isignseq=1
其中:gl_accvouch为凭证明细表,iperiod为会计期,isignseq为凭证类型编号
2、在总帐中查询所有客户某会计期的应收帐款发生额及余额,按客户编码排序(客户科目余额表)
select ccus_id 客户编码,sum(md) 借方金额,sum(mc) 贷方金额,sum(md)-sum(mc) 发生额 from gl_accvouch where iperiod=10 and ccode='112201' and iflag is null group by ccus_id with cube order by ccus_id desc
3、在总帐中查询所有客户某会计期的应收帐款发生额及余额,按客户编码排序(客户科目余额表)
select cr.ccusname 客户名称 ,sum(ga.md) 借方金额,sum(ga.mc) 贷方金额,sum(ga.md)-sum(ga.mc) 发生额 from gl_accvouch as ga inner join customer as cr on ga.ccus_id=cr.cCusCode where ga.iperiod=10 and ga.ccode='112201' and ga.iflag is null group by cr.ccusname with cube order by cr.ccusname desc
select b.ccusname 客户名称 ,b.ccusid 客户编码,a.sum(md) 借方金额,a.sum(mc) 贷方金额 from gl_accvouch a inner join customer b on a.ccus_id=b.ccusid where a.iperiod=10 and a.ccode='112201' group by b.ccusid order by b.ccusid
4、在辅助总账中查询
select ccode,sum(mb) 期初余额,sum(md) 本期借方,sum(mc) 本期贷方,sum(me) 期末余额 from gl_accass where iperiod=1 group by ccode
5、查找出ap_detail中cpzid在gl_accvouch中不存在的记录
select * from ap_detail al where al.cpzid not in(select gh.coutno_id from gl_accvouch gh inner join ap_detail on al.cpzid=gh.coutno_id )
6、distinct
select di |
|