-- -------------------------
-- 调整金额明细表建表
-- -------------------------
drop table if exists dw.dwd_cost_adjust_data_d;
CREATE TABLE IF NOT EXISTS dw.dwd_cost_adjust_data_d (
  year             VARCHAR(100) COMMENT '年'
 ,month            VARCHAR(100) COMMENT '月'
 ,dimsubjectcode   VARCHAR(255) COMMENT '调整组织机构编码'
 ,dimsubjectname   VARCHAR(255) COMMENT '调整组织结构名称'
 ,dimaccountcode   VARCHAR(255) COMMENT '调整预算科目编码'
 ,dimaccountname   VARCHAR(255) COMMENT '调整预算科目名称'
 ,originalcurrency VARCHAR(255) COMMENT '调整金额'
)COMMENT = '费控调整金额明细数据'


-- -------------------------
-- 调整金额明细表转换
-- -------------------------


INSERT INTO dw.dwd_cost_adjust_data_d
SELECT
 year              -- 年
,CASE WHEN  char_length(month) = '1' THEN CONCAT('0',month) ELSE month END AS month -- 月
,dimsubjectcode    -- 调整组织机构编码
,dimsubjectname    -- 调整组织结构名称
,dimaccountcode    -- 调整预算科目编码
,dimaccountname    -- 调整预算科目名称
,originalcurrency  -- 调整金额
FROM dw.ods_cost_adjust_data_d
where dimaccountcode IN ('WY0401','WY040101','WY040102','WY040103','WY040104','WY040105','WY040106','WY040107','WY040108','WY040109','WY040110','WY040111','WY040112','WY040113','WY040114','WY0402','WY040201','WY040202','WY040203','WY040204','WY040205','WY040206','WY040207','WY040208','WY040209','WY040210','WY040211','WY040212','WY040213','WY040214','WY040215','WY040216') -- 仅筛选人力成本和行政成本数据
;

select * from dw.dwd_cost_adjust_data_d;