2025-03-04 10:24:36 +08:00

18 lines
706 B
SQL

INSERT INTO dwd.active_df(relation_id,user_id,ds,ds_date)
SELECT t2.relation_id
,t1.user_id
,t1.ds
,TO_DATE(t1.ds, 'YYYYMMDD') ds_date
FROM pubdata_center.ods.active_account_list t1
INNER JOIN dim.game_product_relation t2
ON t1.channel_id = t2.game_channel_id
AND t1.game_identity = t2.game_identity
AND t1.platform_id = t2.game_platform_id
WHERE t1.ds>='${30_days_later}' and t1.channel_id='${channel_id}' AND t1.game_identity='${game_identity}' AND t1.platform_id='${platform_id}'
GROUP BY t2.relation_id
,t1.user_id
,t1.ds
,TO_DATE(t1.ds, 'YYYYMMDD')
ON CONFLICT (relation_id, user_id, ds)
DO UPDATE SET ds_date = EXCLUDED.ds_date
;