data_job/sql/dwd_before/active_account_df.sql
2025-03-06 13:46:10 +08:00

31 lines
992 B
SQL

-- 根据游戏汇总活跃账号数据 天日增
INSERT INTO dwd.active_account_df(game_channel_id,game_identity,game_platform_id,active_num,ds,ds_type,ds_name)
SELECT channel_id game_channel_id
,game_identity
,platform_id game_platform_id
,count(distinct user_id) active_num
,ds ds
,'d' ds_type
,'' ds_name
FROM ods.active_account_list
WHERE ds = '${bizdate}'
GROUP BY ds
,channel_id
,game_identity
,platform_id
UNION all
SELECT channel_id game_channel_id
,game_identity
,platform_id game_platform_id
,count(distinct user_id) active_num
,'${t_month}' AS ds
,'m' ds_type
,'' ds_name
FROM ods.active_account_list
WHERE ds >= '${t_month}'
AND ds <= '${bizdate}'
GROUP BY channel_id
,game_identity
,platform_id
ON CONFLICT (game_channel_id,game_identity,game_platform_id,ds,ds_type) DO UPDATE SET active_num = EXCLUDED.active_num
;