抽取ods库中customer_inf表中昨天的分区(任务一生成的分区)数据,并结合dim_customer_inf最新分区现有的数据,根据customer_id合并数据到dwd库中
时间: 2023-05-11 19:04:49 浏览: 276
你可以使用以下 SQL 语句来抽取ods库中customer_inf表中昨天的分区数据,并结合dim_customer_inf最新分区现有的数据,根据customer_id合并数据到dwd库中:
INSERT INTO dwd.customer_inf
SELECT
COALESCE(o.customer_id, d.customer_id) AS customer_id,
COALESCE(o.customer_name, d.customer_name) AS customer_name,
COALESCE(o.customer_age, d.customer_age) AS customer_age,
COALESCE(o.customer_gender, d.customer_gender) AS customer_gender,
COALESCE(o.customer_address, d.customer_address) AS customer_address,
COALESCE(o.customer_phone, d.customer_phone) AS customer_phone,
COALESCE(o.customer_email, d.customer_email) AS customer_email,
COALESCE(o.customer_create_time, d.customer_create_time) AS customer_create_time,
COALESCE(o.customer_update_time, d.customer_update_time) AS customer_update_time
FROM
ods.customer_inf_$yesterday o
FULL OUTER JOIN
dim.dim_customer_inf d
ON
o.customer_id = d.customer_id;
其中,$yesterday 是昨天的日期,可以使用相应的函数来获取。
阅读全文