|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
实施时候客户会要求从后台跟踪一下各个子单位的业务录入情况,可以参考以下的语句,语句比较匆忙,没有优化高手可以优化一下,提高效率
一、跟踪客户业务状态:
1.查询客户期初余额和凭证录入进度情况:
--2010年录入过期初余额的公司
select distinct unitcode,unitname from gl_voucher,bd_corp
where gl_voucher.pk_corp=bd_corp.pk_corp and YEAR='2010' AND PERIOD = '00'
order by unitcode
--2010年还没有录入过期初余额的公司
select distinct unitcode,unitname from bd_corp where unitcode not IN
(select distinct unitcode from gl_voucher,bd_corp
where gl_voucher.pk_corp=bd_corp.pk_corp and YEAR='2010' AND PERIOD = '00')
order by unitcode
--2010年录入过凭证的公司
select distinct unitcode,unitname from gl_voucher,bd_corp
where gl_voucher.pk_corp=bd_corp.pk_corp and YEAR='2010' AND PERIOD <> '00'
order by unitcode
--2010年还没有录入过凭证的公司
select distinct unitcode,unitname from bd_corp where unitcode not IN
(select distinct unitcode from gl_voucher,bd_corp
where gl_voucher.pk_corp=bd_corp.pk_corp and YEAR='2010' AND PERIOD <> '00')
order by unitcode
--2010年各公司凭证录入张数
----统计最大凭证号(付)
select distinct unitcode,unitname,max(no),max(prepareddate) from gl_voucher,bd_corp
where gl_voucher.pk_corp=bd_corp.pk_corp
and pk_vouchertype = '0001DEFAULT000000001'
group by unitcode,unitname
order by unitcode
----查看凭证类别pk值
SELECT forshort,pk_vouchertype FROM bd_vouchertype
2.各公司期初建账情况
--查询各个公司的期初建账情况
select distinct unitcode,unitname,builtyear AS 期初建账年度
from gl_initbuild,bd_corp
where gl_initbuild.pk_corp=bd_corp.pk_corp ORDER BY unitcode
--查询2010未期初建账的公司
select distinct unitcode,unitname from bd_corp where unitcode not IN
(select distinct unitcode from gl_initbuild,bd_corp
where gl_initbuild.pk_corp=bd_corp.pk_corp and builtyear = '2010')
ORDER BY bd_corp.unitcode
3.各公司结账情况
SELECT settledperiod AS 最后结账期间,settledyear AS 最后结账年,glorgbookname
FROM gl_syssettled, bd_glorgbook
WHERE gl_syssettled.pk_glorgbook=bd_glorgbook.pk_glorgbook
二、各基础档案录入情况查询:
---1.查询nc用户及对应权限
select unitcode,unitname,user_code,user_name,role_name from sm_user,bd_corp,sm_user_role,sm_role
where sm_user.pk_corp =bd_corp.pk_corp AND sm_user.cuserid=sm_user_role.cuserid
and sm_user_role.pk_role=sm_role.pk_role order by unitcode,user_code
--2.查询报表用户
select u.user_code,u.user_name,unit_code,unit_name
from IUFO_USERINFO u inner join IUFO_UNIT_INFO unit on u.UNIT_ID = unit.unit_id;
--3.报表单位查询
--查询报表中某省下的单位档案(部门)
select unit_id,unit_code,unit_name from iufo_unit_info WHERE unit_code LIKE '71%' ORDER BY unit_code
--查询报表中全部公司单位档案(部门)
select unit_id,unit_code,unit_name from iufo_unit_info ORDER BY unit_code
--4.现金流量科目绑定查询
--现金流--科目主键为贷方:
select gl_subrelation.iscd,gl_subrelation.isdd,bd_accsubj.subjcode,bd_accsubj.subjname,bd_cashflow.cfitemcode,bd_cashflow.cfitemname
from gl_subrelation,bd_accsubj,bd_cashflow
where gl_subrelation.pk_cashflow=bd_cashflow.pk_cashflow
and bd_accsubj.pk_accsubj=gl_subrelation.pk_creditsubject
--现金流--科目主键为借方:
select gl_subrelation.iscd,gl_subrelation.isdd,bd_accsubj.subjcode,bd_accsubj.subjname,bd_cashflow.cfitemcode,bd_cashflow.cfitemname
from gl_subrelation,bd_accsubj,bd_cashflow
where gl_subrelation.pk_cashflow=bd_cashflow.pk_cashflow
and bd_accsubj.pk_accsubj=gl_subrelation.pk_debitsubject
5.---部门及对应公司列表
SELECT unitcode,unitname,deptcode,deptname FROM bd_corp,bd_deptdoc WHERE bd_deptdoc.pk_corp=bd_corp.pk_corp ORDER BY unitcode,deptcode
-统计各公司部门数量
select bdc.unitcode,count(bdc.unitcode) from bd_deptdoc bdd,bd_corp bdc where bdd.pk_corp=bdc.pk_corp group by bdc.unitcode order by unitcode
--按公司统计部门明细
select * from bd_deptdoc,bd_corp where bd_deptdoc.pk_corp=bd_corp.pk_corp and unitcode like '71%'
6.--各公司列表
select unitcode,unitname from bd_corp order by unitcode
7.--统计每个供公司录入外部客商档案的记录数(体系内0001G51、体系外0001991)
select unitcode,count(unitcode) from bd_cubasdoc aa,bd_corp bb
where aa.pk_areacl LIKE ('0001991%') and aa.pk_corp=bb.pk_corp
group by unitcode order by unitcode
select unitname,unitcode,count(unitcode) from bd_cubasdoc aa
right join bd_corp bb on aa.pk_corp=bb.pk_corp
where aa.pk_areacl like ('0001G51%')
group by unitcode,unitname order by unitcode |
|