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-11-27 11:07:58 +08:00
originalcurrency VARCHAR(255) COMMENT '调整金额'
2024-07-21 22:06:45 +08:00
,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
2024-11-27 11:07:58 +08:00
sum(originalcurrency) as originalcurrency -- 调整金额
,dimaccountcode as dimaccountcode -- 调整预算科目编码
,dimaccountname as dimaccountname -- 调整预算科目名称
,DimSubjectcode as DimSubjectcode -- 调整组织机构编码
,DimSubjectname as DimSubjectname -- 调整组织结构名称
,year as year -- 年
,month as month -- 月
2024-07-21 22:06:45 +08:00
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
2024-11-27 11:07:58 +08:00
from(SELECT * FROM e7fssc_ld.t_cc_billmaindata where billtype=6 and currentstate=21) m
2024-07-21 22:06:45 +08:00
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
2024-11-27 11:07:58 +08:00
-- 根据实际业务需求去添加 start
-- and a.dimaccountcode='' -- 调整预算科目编码,如果查该组织机构下所有的科目,把该条件注释掉即可
-- and a.DimSubjectcode='010201011105' -- 调整预算组织名称
and a.year='2024' --
-- and a.month='01' --调整月
-- 根据实际业务需求去添加 end
2024-07-21 22:06:45 +08:00
group by
dimaccountcode
,dimaccountname
,DimSubjectcode
,DimSubjectname
,year
2024-07-22 18:51:46 +08:00
,month
;