54 lines
2.2 KiB
MySQL
54 lines
2.2 KiB
MySQL
|
|
||
|
drop table if exists dw.ods_cost_adjust_data_d;
|
||
|
CREATE TABLE IF NOT EXISTS dw. (
|
||
|
originalcurrency VARCHAR(255) COMMENT '调整金额'
|
||
|
,dimaccountcode VARCHAR(255) COMMENT '调整预算科目编码'
|
||
|
,dimaccountname VARCHAR(255) COMMENT '调整预算科目名称'
|
||
|
,dimsubjectcode VARCHAR(255) COMMENT '调整组织机构编码'
|
||
|
,dimsubjectname VARCHAR(255) COMMENT '调整组织结构名称'
|
||
|
,year VARCHAR(100) COMMENT '年'
|
||
|
,month VARCHAR(100) COMMENT '月'
|
||
|
)COMMENT = '费控调整金额数据'
|
||
|
|
||
|
|
||
|
select
|
||
|
sum(originalcurrency) as originalcurrency --调整金额
|
||
|
,dimaccountcode as dimaccountcode --调整预算科目编码
|
||
|
,dimaccountname as dimaccountname --调整预算科目名称
|
||
|
,DimSubjectcode as DimSubjectcode --调整组织机构编码
|
||
|
,DimSubjectname as DimSubjectname --调整组织结构名称
|
||
|
,year as year --年
|
||
|
,month as month --月
|
||
|
from
|
||
|
(
|
||
|
select
|
||
|
distinct
|
||
|
o.objectcode as dimaccountcode
|
||
|
,o.objectname as dimaccountname
|
||
|
,o1.objectcode as DimSubjectcode
|
||
|
,o1.objectname as DimSubjectname
|
||
|
,substr(d.budgetdetaildate,0,4)as year
|
||
|
,substr(d.budgetdetaildate,6,7)as month
|
||
|
,d.originalcurrency
|
||
|
from e7fssc_ld.t_cc_billmaindata m
|
||
|
left join e7fssc_ld.t_cc_billdetaildata d on d.billmaindataid=d.billmaindataid
|
||
|
left join e7fssc_ld.t_cc_object o on o.objectid=d.dimaccount
|
||
|
left join e7fssc_ld.t_cc_object o1 on o1.objectid=d.dimsubject
|
||
|
where m.billtype=6
|
||
|
and m.currentstate=21
|
||
|
and budgetdetaildate is not null
|
||
|
) a
|
||
|
where 1=1
|
||
|
---根据实际业务需求去添加 start
|
||
|
-- and a.dimaccountcode='' --调整预算科目编码,如果查该组织机构下所有的科目,把该条件注释掉即可
|
||
|
--and a.DimSubjectcode='010201011105' --调整预算组织名称
|
||
|
and a.year='2024' --调整年
|
||
|
--and a.month='01' --调整月
|
||
|
---根据实际业务需求去添加 end
|
||
|
group by
|
||
|
dimaccountcode
|
||
|
,dimaccountname
|
||
|
,DimSubjectcode
|
||
|
,DimSubjectname
|
||
|
,year
|
||
|
,month
|