Files
MarketAnalysis-ETL/CHPA/02 tmp_ims_td_prod_tmp.sql
2026-05-13 12:38:21 +00:00

32 lines
1000 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- Databricks notebook source
-- DBTITLE 1,产品挂中文名
--Product中文名字,若有超过5个CORP或者MANU生产则将其报告上排序的优先级调低
insert overwrite table tmp.tmp_ims_td_prod_tmp
SELECT DISTINCT PROD.PROD_COD
FROM dws.dws_ims_td_prod_cn PROD
LEFT JOIN dwd.dwd_ims_td_pack_property PACK
ON PROD.PROD_COD = PACK.PROD_COD
LEFT JOIN dws.dws_ims_td_corp_cn CORP
ON PACK.CORP_COD = CORP.CORP_COD
WHERE PROD.PROD_DES_C IN
(
--先计算出超过10个厂家生产的Prod_CN
--先计算出有多个厂家生产的Prod_CN
SELECT PROD.PROD_DES_C
FROM dwd.dwd_ims_td_pack_property PACK
LEFT JOIN dws.dws_ims_td_prod_cn PROD
ON PACK.PROD_COD = PROD.PROD_COD
GROUP BY PROD.PROD_DES_C
HAVING ( COUNT(DISTINCT CORP_DES) > 5 OR COUNT(DISTINCT MANU_DES) > 5 )
AND PROD.PROD_DES_C IS NOT NULL
);
-- COMMAND ----------
UPDATE dws.dws_ims_td_prod_cn SET RANK_TYPE = 0 where PROD_COD in (
SELECT DISTINCT PROD_COD FROM tmp.tmp_ims_td_prod_tmp
);