leading-project/dw/ods/ods_cost_adjust_data_d.sql

55 lines
2.3 KiB
MySQL
Raw Normal View History

2024-07-21 22:06:45 +08:00
drop table if exists dw.ods_cost_adjust_data_d;
2024-07-22 18:51:46 +08:00
CREATE TABLE IF NOT EXISTS dw.ods_cost_adjust_data_d (
2024-07-21 22:06:45 +08:00
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 ''
2024-07-22 18:51:46 +08:00
)COMMENT = '费控调整金额数据';
2024-07-21 22:06:45 +08:00
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
2024-07-22 18:51:46 +08:00
,month
;