20260429chenwu

zhouxin & chenwu 修改
This commit is contained in:
2026-04-29 15:57:22 +00:00
parent d0753fc790
commit 550df7d257
8 changed files with 225 additions and 129 deletions

View File

@@ -227,9 +227,7 @@ ON t1.PACK_COD = t2.PACK_COD
--audit_cod在事实表有销量audit_cod
--audit_cod
with sales as (
select distinct PACK_COD,AUDIT_COD,DATA_SOURCE from dm.DM_TF_EXT_UNIONALL_SALES
union
select distinct PACK_COD,AUDIT_COD,DATA_SOURCE from dm.dm_tf_external_sales_thc
select distinct PACK_CODE,AUDIT_CODE,DATA_SOURCE from dm.DM_TF_EXT_UNIONALL_SALES
)
,market_pack as (
select distinct PACK_COD,MARKET,DATA_SOURCE from dm.dm_td_external_market_pack_mapping
@@ -238,10 +236,10 @@ select distinct PACK_COD,MARKET,DATA_SOURCE from dm.dm_td_external_market_pack_m
select distinct AUDIT_COD,MARKET,DATA_SOURCE from dm.DM_TD_EXT_THC_ORG
)
,tmp_org as (
select distinct a.AUDIT_COD,b.MARKET,a.DATA_SOURCE
select distinct a.AUDIT_CODE,b.MARKET,a.DATA_SOURCE
from sales a
left join market_pack b on a.PACK_COD = b.PACK_COD and a.DATA_SOURCE = b.DATA_SOURCE
left join org c on a.DATA_SOURCE = c.DATA_SOURCE and a.AUDIT_COD = c.AUDIT_COD and b.MARKET = c.MARKET
left join market_pack b on a.PACK_CODE = b.PACK_COD and a.DATA_SOURCE = b.DATA_SOURCE
left join org c on a.DATA_SOURCE = c.DATA_SOURCE and a.AUDIT_CODE = c.AUDIT_COD and b.MARKET = c.MARKET
where C.AUDIT_COD IS NULL
)
@@ -283,7 +281,7 @@ select
'ROC' as rc_name_en,
'Vacant' as RC_Name,
null as RegionCenter,
AUDIT_COD,
AUDIT_CODE,
MARKET,
null as bu_category,
null as bu_name_en,
@@ -337,4 +335,4 @@ USING hidden_market t2
on t1.data_source = t2.data_source
and upper(t1.MARKET) = upper(t2.hidden_market)
WHEN MATCHED THEN
DELETE
DELETE