-- Databricks notebook source
insert overwrite table dm.dm_tf_external_sales
(YYYYMM,
PACK_COD,
CORP_COD,
AUDIT_COD,
PLATFORM_TYPE,
STORE_NAME,
STORE_TYPE,
REGION_TYPE,
PACK_FLAG,
PROD_FLAG,
DTP_FLAG,
SALES_UNIT_CAL,
SALES_UNIT_CAL_LY,
SALES_VALUE_CAL,
SALES_VALUE_CAL_LY,
CONUTING_UNIT,
CONUTING_UNIT_LY,
DATA_SOURCE,
inst_code,
cmps_flag,
dept_name,
prescription,
prescription_ly,
new_code,
area,
h_level,
reimburse,
reimburse_type,
prescription_source
)
select
YYYYMM,
PACK_CODE AS PACK_COD,
CORP_CODE AS CORP_COD,
AUDIT_CODE AS AUDIT_COD,
PLATFORM_TYPE,
STORE_NAME,
STORE_TYPE,
REGION_TYPE,
PACK_FLAG,
PROD_FLAG,
DTP_FLAG,
SALES_UNIT_CAL,
SALES_UNIT_CAL_LY,
SALES_VALUE_CAL,
SALES_VALUE_CAL_LY,
CONUTING_UNIT,
CONUTING_UNIT_LY,
DATA_SOURCE,
inst_code,
cmps_flag,
dept_name,
prescription,
prescription_ly,
new_code,
area,
h_level,
reimburse,
reimburse_type,
prescription_source
from  
  dm.DM_TF_EXT_UNIONALL_SALES