This commit is contained in:
尹舟 2025-04-30 17:17:09 +08:00
parent 107c2780c4
commit 386213caee
23 changed files with 1886 additions and 1 deletions

View File

@ -74,4 +74,7 @@ SELECT
FROM hm.sale_detail
INNER JOIN hm.user_info FOR SYSTEM_TIME AS OF PROCTIME()
ON sale_detail.uid =user_info.uid
GROUP BY sale_detail.app_id,sale_detail.uid,sale_detail.product,sale_detail.order_time,user_info.province,user_info.city;
GROUP BY sale_detail.app_id,sale_detail.uid,sale_detail.product,sale_detail.order_time,user_info.province,user_info.city;
DROP DYNAMIC TABLE ads.q1_full;

View File

@ -0,0 +1,178 @@
CREATE TABLE datasci.ads_996eco_index_box_d (
index_type text,
data_day text,
is_box text,
dau bigint,
pay_cnt bigint,
pay_amount bigint,
)
;
DELETE FROM datasci.ads_996eco_index_box_d WHERE data_day = '${biz-date}';
-- dau
WITH game_apply AS
(
SELECT id
,name
,bind_game_id
FROM public.gm_apply
WHERE bind_game_type = 1
)
INSERT INTO
datasci.ads_996eco_index_box_d (index_type,data_day,is_box,dau)
SELECT 'dau' AS index_type
,dt data_day
,CASE WHEN GROUPING(user_flag) = 0 THEN user_flag
ELSE '总计'
END AS is_box
,uniq(user_id) AS dau
FROM (
SELECT ds::date AS dt
,CASE WHEN t1.channel LIKE '%996box%' THEN '盒子'
ELSE '非盒子'
END AS user_flag
,user_id
FROM public.ods_active_account t1
INNER JOIN game_apply t2
ON t1.appid = t2.id
WHERE t1.ds = '${bizdate}'
) t
GROUP BY
GROUPING SETS (dt,user_flag)
,(dt)
;
-- reg
WITH legend_apps AS
(
SELECT id AS appid
FROM gm_apply
WHERE bind_game_type = 1
AND bind_type = 1 -- 默认应用
)
---
,tmp_ods_newly_account AS
(
SELECT *
FROM ods_newly_account
WHERE ds = '${bizdate}'
)
,box_users AS
(
SELECT user_id
FROM tmp_ods_newly_account
WHERE appid = 1015
OR channel ~ '996box'
OR channel IN (
SELECT value AS channel
FROM public.dws_app_props
WHERE appid = 1015
AND prop = 2
)
GROUP BY user_id
)
-- 筛选出有盒子记录以及玩过传奇游戏的玩家
,box_users_with_legend AS
(
SELECT acc.user_id
FROM tmp_ods_newly_account acc
WHERE
EXISTS(
SELECT 1
FROM legend_apps app
WHERE acc.appid = app.appid
)
AND
EXISTS(
SELECT 1
FROM box_users box
WHERE box.user_id = acc.user_id
)
)
,reg_account AS
(
-- 普通用户的传奇记录
SELECT acc.gmid
,acc.appid
,acc.channel
,acc.user_id
,acc.device_type
,acc.event_time
,acc.ds
,'非盒子用户' AS user_flag --
,'0' AS sub_channel
FROM tmp_ods_newly_account acc
WHERE
EXISTS(
SELECT 1
FROM legend_apps app
WHERE app.appid = acc.appid
)
AND NOT
EXISTS(
SELECT 1
FROM box_users box
WHERE box.user_id = acc.user_id
)
UNION ALL -- 盒子用户玩过传奇的全量记录
SELECT acc.gmid
,acc.appid
,CASE WHEN bxchl.channel_desc IS NOT NULL THEN bxchl.channel_desc
ELSE acc.channel
END AS channel
,acc.user_id
,acc.device_type
,acc.event_time
,acc.ds
,'盒子用户' AS user_flag ---
,bxchl.channel_desc AS sub_channel
FROM tmp_ods_newly_account acc
LEFT JOIN (
SELECT appid
,value AS channel
,ext AS channel_desc
FROM public.dws_app_props
WHERE appid = 1015
AND prop = 2 -- and length(ext)>0
) bxchl
ON acc.appid = bxchl.appid
AND acc.channel = bxchl.channel
WHERE
EXISTS(
SELECT 1
FROM box_users_with_legend b
WHERE b.user_id = acc.user_id
)
)
INSERT INTO
datasci.ads_996eco_index_box_d (index_type,data_month,is_box,reg_count)
SELECT 'reg' index_type
,'${biz-date}' AS data_day
,CASE WHEN user_flag = '非盒子用户' THEN '非盒子注册用户'
WHEN user_flag = '盒子用户'
AND (appid = 1015
OR channel ~ '996box'
OR sub_channel IS NOT NULL) THEN '盒子注册用户'
ELSE '非盒子注册用户'
END AS is_box
,uniq(mi.user_id) AS reg_count
FROM reg_account acc
INNER JOIN (
SELECT user_id
,MIN(event_time) AS event_time_min
FROM reg_account
GROUP BY user_id
) mi ---
ON acc.user_id = mi.user_id
AND acc.event_time = mi.event_time_min
GROUP BY 1
,2
,3
;

View File

@ -0,0 +1,281 @@
CREATE TABLE datasci.ads_996eco_index_box_m (
index_type text,
data_month text,
is_box text,
act_cnt bigint,
pay_cnt bigint,
pay_amount bigint,
mau bigint,
device_type text,
device_type_new text,
act_num bigint,
reg_count bigint,
);
DELETE FROM datasci.ads_996eco_index_box_m WHERE ds = '${month}';
--
WITH ga AS
(
SELECT id
,name
,bind_game_id
FROM public.gm_apply
WHERE bind_type = 1
AND bind_game_type = 1
)
,box_users AS
(
SELECT user_id
FROM public.ods_newly_account
WHERE appid = 1015
GROUP BY user_id
)
,po AS
(
SELECT appid
,user_id
,amount / 100 AS pay_amount
FROM public.ods_payment_order
WHERE ds BETWEEN '${bizmonth}' AND '${bizdate}'
AND status = 1
)
,aa AS
(
SELECT appid
,user_id
FROM public.ods_active_account
WHERE ds BETWEEN '${bizmonth}' AND '${bizdate}'
)
INSERT INTO
datasci.ads_996eco_index_box_m (index_type,data_month,is_box,act_cnt,pay_cnt,pay_amount)
SELECT 'pay' AS index_type
,'${month}' data_month
,t1.is_box
,t1.act_cnt
,t2.pay_cnt
,t2.pay_amount
FROM (
SELECT CASE WHEN bu.user_id IS NOT NULL THEN '盒子'
ELSE '非盒子'
END AS is_box
,UNIQ(aa.user_id) AS act_cnt
FROM aa
INNER JOIN ga
ON aa.appid = ga.id
LEFT JOIN box_users bu
ON bu.user_id = aa.user_id
GROUP BY 1
) t1
LEFT JOIN (
SELECT CASE WHEN bu.user_id IS NOT NULL THEN '盒子'
ELSE '非盒子'
END AS is_box
,UNIQ(po.user_id) AS pay_cnt
,SUM(po.pay_amount) AS pay_amount
FROM po
INNER JOIN ga
ON po.appid = ga.id
LEFT JOIN box_users bu
ON bu.user_id = po.user_id
GROUP BY 1
) t2
ON t1.is_box = t2.is_box
;
-- mau
WITH game_apply AS
(
SELECT id
,name
,bind_game_id
FROM public.gm_apply
WHERE bind_game_type = 1
)
INSERT INTO
datasci.ads_996eco_index_box_m (index_type,data_month,is_box,mau)
SELECT 'mau' index_type
,'${month}' data_month
,CASE WHEN grouping(user_flag) = 0 THEN user_flag
ELSE '总计'
END AS is_box
,uniq(user_id) AS mau
FROM (
SELECT CASE WHEN t1.channel LIKE '%996box%' THEN '盒子'
ELSE '非盒子'
END AS user_flag
,user_id
FROM public.ods_active_account t1
INNER JOIN game_apply t2
ON t1.appid = t2.id
WHERE t1.ds BETWEEN '${hisdate}' AND '${bizdate}'
) t
GROUP BY user_flag
;
-- mau-device
WITH game_apply AS
(
SELECT id
,name
,bind_game_id
FROM public.gm_apply
WHERE bind_game_type = 1
)
INSERT INTO
datasci.ads_996eco_index_box_m (index_type,data_month,is_box,device_type,device_type_new,act_num)
SELECT 'mau-device' index_type
,'${month}' AS data_month
,CASE WHEN t1.channel LIKE '%996box%' THEN '盒子'
ELSE '非盒子'
END AS is_box
,t1.device_type
,CASE WHEN lower(t1.device_type) LIKE '%h5%' THEN 'H5'
WHEN lower(t1.device_type) LIKE '%pc%' THEN 'PC'
WHEN lower(t1.device_type) LIKE '%ios%' THEN 'IOS'
ELSE t1.device_type
END AS device_type_new
,uniq(user_id) AS act_num
FROM public.ods_active_account t1
INNER JOIN game_apply t2
ON t1.appid = t2.id
WHERE t1.ds BETWEEN '${hisdate}' AND '${bizdate}'
GROUP BY 1,2,3,4
;
-- reg
WITH legend_apps AS
(
SELECT id AS appid
FROM gm_apply
WHERE bind_game_type = 1
AND bind_type = 1 -- 默认应用
)
---
,tmp_ods_newly_account AS
(
SELECT *
FROM ods_newly_account
WHERE ds BETWEEN '${hisdate}' AND '${bizdate}'
)
,box_users AS
(
SELECT user_id
FROM tmp_ods_newly_account
WHERE appid = 1015
OR channel ~ '996box'
OR channel IN (
SELECT value AS channel
FROM public.dws_app_props
WHERE appid = 1015
AND prop = 2
)
GROUP BY user_id
)
-- 筛选出有盒子记录以及玩过传奇游戏的玩家
,box_users_with_legend AS
(
SELECT acc.user_id
FROM tmp_ods_newly_account acc
WHERE
EXISTS(
SELECT 1
FROM legend_apps app
WHERE acc.appid = app.appid
)
AND
EXISTS(
SELECT 1
FROM box_users box
WHERE box.user_id = acc.user_id
)
)
,reg_account AS
(
-- 普通用户的传奇记录
SELECT acc.gmid
,acc.appid
,acc.channel
,acc.user_id
,acc.device_type
,acc.event_time
,acc.ds
,'非盒子用户' AS user_flag --
,'0' AS sub_channel
FROM tmp_ods_newly_account acc
WHERE
EXISTS(
SELECT 1
FROM legend_apps app
WHERE app.appid = acc.appid
)
AND NOT
EXISTS(
SELECT 1
FROM box_users box
WHERE box.user_id = acc.user_id
)
UNION ALL -- 盒子用户玩过传奇的全量记录
SELECT acc.gmid
,acc.appid
,CASE WHEN bxchl.channel_desc IS NOT NULL THEN bxchl.channel_desc
ELSE acc.channel
END AS channel
,acc.user_id
,acc.device_type
,acc.event_time
,acc.ds
,'盒子用户' AS user_flag ---
,bxchl.channel_desc AS sub_channel
FROM tmp_ods_newly_account acc
LEFT JOIN (
SELECT appid
,value AS channel
,ext AS channel_desc
FROM public.dws_app_props
WHERE appid = 1015
AND prop = 2 -- and length(ext)>0
) bxchl
ON acc.appid = bxchl.appid
AND acc.channel = bxchl.channel
WHERE
EXISTS(
SELECT 1
FROM box_users_with_legend b
WHERE b.user_id = acc.user_id
)
)
INSERT INTO
datasci.ads_996eco_index_box_m (index_type,data_month,is_box,reg_count)
SELECT 'reg' index_type
,'${month}' AS data_month
,CASE WHEN user_flag = '非盒子用户' THEN '非盒子注册用户'
WHEN user_flag = '盒子用户'
AND (appid = 1015
OR channel ~ '996box'
OR sub_channel IS NOT NULL) THEN '盒子注册用户'
ELSE '非盒子注册用户'
END AS is_box
,uniq(mi.user_id) AS reg_count
FROM reg_account acc
INNER JOIN (
SELECT user_id
,MIN(event_time) AS event_time_min
FROM reg_account
GROUP BY user_id
) mi ---
ON acc.user_id = mi.user_id
AND acc.event_time = mi.event_time_min
GROUP BY 1
,2
,3
;

View File

@ -0,0 +1,551 @@
CREATE TABLE datasci.ads_996eco_index_channel_m (
index_type text,
data_month text,
re_channel text,
pay_cnt bigint,
pay_amount bigint,
pay_amount bigint,
mau bigint,
device_type text,
device_type_new text,
act_num bigint,
reg_count bigint,
);
DELETE FROM datasci.ads_996eco_index_channel_m WHERE ds = '${month}';
--
--
WITH ga AS (
SELECT
id,
name
FROM public.gm_apply
WHERE bind_type = 1 AND bind_game_type = 1
)
,
po AS (
SELECT
appid,
ds::date ds,
user_id,
case when channel~*'996box' then '盒子'
when channel~'ai6' then 'ai6'
when channel~'玩心' then '玩心'
when channel~'应用宝' then '腾讯应用宝'
when channel~'纸片' then '纸片'
when channel~'团团' then '团团'
when channel~'335玩' then '335玩'
when channel~'朋克' then '朋克'
when channel~'安徽追游' then '安徽追游'
when channel~'冰火' then '冰火'
when channel~'心乐' then '心乐'
when channel ~*'华为|vivo|oppo|魅族|努比亚|联想|酷派' then '硬核联盟'
when channel~'9377' then '9377'
when channel~'智灵' then '智灵'
when channel~'掌游' then '掌游'
when channel~'上士' then '上士'
when channel~'攒趣' then '攒趣'
when channel~'掌玩' then '掌玩'
when channel~'贪玩' then '贪玩'
when channel~*'wx|微信' then '微信'
when channel~'公众号' then '公众号'
when channel~*'qq' then 'QQ'
when channel~'七牛' then '七牛'
when channel~'霸气' then '霸气'
when channel~*'xy' then 'XY'
when channel~'芝麻互娱' then '芝麻互娱'
when channel~'龙翔' then '龙翔'
when channel~'布咕' then '布咕'
when channel~'小柠互娱' then '小柠互娱'
when channel~'春秋玩' then '春秋玩'
when channel~'欢喜时代' then '欢喜时代'
when channel~'上游' then '上游'
when channel~'倾程' then '倾程'
when channel~'绿洲' then '绿洲'
when channel~'雷电' then '雷电'
when channel~'点点' then '点点'
when channel~'小七' then '小七'
when channel~'瓜玩' then '瓜玩'
when channel~'艺云' then '艺云'
when channel~'冠游' then '冠游'
when channel~'玄藏' then '玄藏'
when channel~'羽龙' then '羽龙'
when channel~'星云' then '星云'
when channel~'爱尚游' then '爱尚游'
when channel~'昊玩' then '昊玩'
when channel~'8酷' then '8酷'
when channel~'迅玩' then '迅玩'
when channel~'星游' then '星游'
when channel~'小米' then '小米'
when channel~'趣城' then '趣城'
when channel~'诺游' then '诺游'
when channel~'洛谷' then '洛谷'
when channel~'司墨' then '司墨'
when channel~'脚印' then '脚印'
when channel~'神游' then '神游'
when channel~'拓乐' then '拓乐'
when channel~'360' then '360'
when channel~'日昇' then '日昇'
when channel~'触点' then '触点'
when channel~'冠游' then '冠游'
when channel~'巴兔' then '巴兔'
when channel~'天纵' then '天纵'
when channel~'早游戏' then '早游戏'
when channel~'爱趣' then '爱趣'
when channel~'星楠祥' then '星楠祥'
when channel~'贪游' then '贪游'
when channel~'君游' then '君游'
when channel~'996直播间' then '996直播间'
when channel~'mumu' then 'mumu'
when channel~'吉祥' then '吉祥直播间'
when channel~'溪谷' then '溪谷'
when channel~'优谷' then '优谷'
when channel~'闪趣' then '闪趣'
when channel~'8酷' then '8酷'
when channel~'抖音' then '抖音'
when channel~'斗鱼' then '斗鱼'
when channel~'虎牙' then '虎牙'
when channel~'巨量' then '巨量'
when channel~'快手' then '快手'
when channel~'爱奇艺' then '爱奇艺'
when channel~'007' then '007'
when channel~'圣宏' then '圣宏'
when channel~'顺火' then '顺火'
when channel~'飞火' then '飞火'
when channel~'乐岛' then '乐岛'
when channel~'传柒' then '传柒'
when channel~'星际' then '星际'
when channel~'玖趣' then '玖趣'
when channel~*'ku25' then 'ku25'
when channel~'8090' then '8090'
when channel~*'appstore' then 'AppStore'
when channel~'欢娱' then '欢娱'
when channel~'逐梦' then '逐梦'
when channel~'兴动' then '兴动'
when channel~'3733' then '3733'
when channel~'第一游戏' then '第一游戏'
when channel~'公会' then '公会'
when channel~'欢娱' then '欢娱'
when channel~'335玩' then '335玩'
when channel~*'4yx' then '4yx'
when channel~'37' then '37'
when channel~'开心' then '开心'
when channel~* 'ios|苹果' then 'ios苹果端具体不详'
when channel~'触点' then '触点'
when channel~'游码' then '游码'
when channel~*'45yx' then '45yx'
when channel~'巨量' then '巨量'
when channel~'小铃铛' then '小铃铛'
when channel~'2345' then '2345'
when channel~'梨子' then '梨子'
when channel~'麦游' then '麦游'
when channel~'群英' then '群英'
when channel~'阅文' then '阅文'
when channel~*'kopo' then 'kopo'
when channel~'创启' then '创启'
when channel~'4366' then '4366'
when channel~'大楚' then '大楚'
when channel~'巅峰' then '巅峰'
when channel~'277' then '277'
when channel~'112233' then '112233'
when channel~'714' then '714'
when channel~'4399' then '4399'
when channel~'追忆' then '追忆'
when channel~*'yy' then 'yy'
when channel~'588' then '588'
when channel~'八门' then '八门'
when channel~*'pdd' then 'pdd'
when channel~'9917' then '9917'
when channel~'51517' then '51517'
when channel~*'4yx' then '4yx'
when channel~'好汉' then '好汉'
when channel~'51' then '51'
when channel~'葫芦侠' then '葫芦侠'
when channel~'虫虫' then '虫虫'
when channel~'跃游' then '跃游'
when channel~'天天' then '天天'
when channel~'66' then '66'
when channel~'嘉禾' then '嘉禾'
when channel~'爱游' then '爱游'
when channel~'乐疯玩' then '乐疯玩'
when channel~'游戏饭' then '游戏饭'
else '其他' end as re_channel,
amount / 100 AS pay_amount
FROM public.ods_payment_order
WHERE status = 1
AND ds BETWEEN '${bizmonth}' AND '${bizdate}'
)
INSERT INTO
datasci.ads_996eco_index_channel_m (index_type,data_month,re_channel,pay_cnt,pay_amount)
SELECT
'pay' AS index_type,
'${month}' AS data_month,
re_channel,
UNIQ(po.user_id) AS pay_cnt,
SUM(po.pay_amount) AS pay_amount
FROM po
INNER JOIN
ga ON po.appid = ga.id
LEFT JOIN
public.ods_newly_account na ON po.appid = na.appid AND po.user_id = na.user_id
GROUP BY 1,2,3
;
-- mau
WITH game_apply AS
(
SELECT id
,name
,bind_game_id
FROM public.gm_apply
WHERE bind_game_type = 1
)
INSERT INTO
datasci.ads_996eco_index_box_m (index_type,data_month,is_box,mau)
SELECT 'mau' index_type
,'${month}' data_month
,CASE WHEN grouping(user_flag) = 0 THEN user_flag
ELSE '总计'
END AS is_box
,uniq(user_id) AS mau
FROM (
SELECT CASE WHEN t1.channel LIKE '%996box%' THEN '盒子'
ELSE '非盒子'
END AS user_flag
,user_id
FROM public.ods_active_account t1
INNER JOIN game_apply t2
ON t1.appid = t2.id
WHERE t1.ds BETWEEN '${hisdate}' AND '${bizdate}'
) t
GROUP BY user_flag
;
-- mau-device
WITH game_apply AS
(
SELECT id
,name
,bind_game_id
FROM public.gm_apply
WHERE bind_game_type = 1
)
INSERT INTO
datasci.ads_996eco_index_box_m (index_type,data_month,is_box,device_type,device_type_new,act_num)
SELECT 'mau-device' index_type
,'${month}' AS data_month
,CASE WHEN t1.channel LIKE '%996box%' THEN '盒子'
ELSE '非盒子'
END AS is_box
,t1.device_type
,CASE WHEN lower(t1.device_type) LIKE '%h5%' THEN 'H5'
WHEN lower(t1.device_type) LIKE '%pc%' THEN 'PC'
WHEN lower(t1.device_type) LIKE '%ios%' THEN 'IOS'
ELSE t1.device_type
END AS device_type_new
,uniq(user_id) AS act_num
FROM public.ods_active_account t1
INNER JOIN game_apply t2
ON t1.appid = t2.id
WHERE t1.ds BETWEEN '${hisdate}' AND '${bizdate}'
GROUP BY 1,2,3,4
;
-- reg
WITH legend_apps AS
(
SELECT id AS appid
FROM gm_apply
WHERE bind_game_type = 1
AND bind_type = 1 -- 默认应用
)
---
,tmp_ods_newly_account AS
(
SELECT *
FROM ods_newly_account
WHERE ds BETWEEN '${hisdate}' AND '${bizdate}'
)
,box_users AS
(
SELECT user_id
FROM tmp_ods_newly_account
WHERE appid = 1015
OR channel ~ '996box'
OR channel IN (
SELECT value AS channel
FROM public.dws_app_props
WHERE appid = 1015
AND prop = 2
)
GROUP BY user_id
)
-- 筛选出有盒子记录以及玩过传奇游戏的玩家
,box_users_with_legend AS
(
SELECT acc.user_id
FROM tmp_ods_newly_account acc
WHERE
EXISTS(
SELECT 1
FROM legend_apps app
WHERE acc.appid = app.appid
)
AND
EXISTS(
SELECT 1
FROM box_users box
WHERE box.user_id = acc.user_id
)
)
,reg_account AS
(
-- 普通用户的传奇记录
SELECT acc.gmid
,acc.appid
,acc.channel
,acc.user_id
,acc.device_type
,acc.event_time
,acc.ds
,'非盒子用户' AS user_flag --
,'0' AS sub_channel
FROM tmp_ods_newly_account acc
WHERE
EXISTS(
SELECT 1
FROM legend_apps app
WHERE app.appid = acc.appid
)
AND NOT
EXISTS(
SELECT 1
FROM box_users box
WHERE box.user_id = acc.user_id
)
UNION ALL -- 盒子用户玩过传奇的全量记录
SELECT acc.gmid
,acc.appid
,CASE WHEN bxchl.channel_desc IS NOT NULL THEN bxchl.channel_desc
ELSE acc.channel
END AS channel
,acc.user_id
,acc.device_type
,acc.event_time
,acc.ds
,'盒子用户' AS user_flag ---
,bxchl.channel_desc AS sub_channel
FROM tmp_ods_newly_account acc
LEFT JOIN (
SELECT appid
,value AS channel
,ext AS channel_desc
FROM public.dws_app_props
WHERE appid = 1015
AND prop = 2 -- and length(ext)>0
) bxchl
ON acc.appid = bxchl.appid
AND acc.channel = bxchl.channel
WHERE
EXISTS(
SELECT 1
FROM box_users_with_legend b
WHERE b.user_id = acc.user_id
)
)
INSERT INTO
datasci.ads_996eco_index_box_m (index_type,data_month,is_box,reg_count)
SELECT 'reg' index_type
,'${month}' AS data_month
,CASE WHEN user_flag = '非盒子用户' THEN '非盒子注册用户'
WHEN user_flag = '盒子用户'
AND (appid = 1015
OR channel ~ '996box'
OR sub_channel IS NOT NULL) THEN '盒子注册用户'
ELSE '非盒子注册用户'
END AS is_box
,uniq(mi.user_id) AS reg_count
FROM reg_account acc
INNER JOIN (
SELECT user_id
,MIN(event_time) AS event_time_min
FROM reg_account
GROUP BY user_id
) mi ---
ON acc.user_id = mi.user_id
AND acc.event_time = mi.event_time_min
GROUP BY 1
,2
,3
;
INSERT INTO
datasci.ads_996eco_index_channel_m (index_type,data_month,re_channel,mau)
select
'mau' index_type,
'${month}' data_month,
case when channel~'盒子' or channel~'996box' then '盒子'
when channel~'ai6' then 'ai6'
when channel~'玩心' then '玩心'
when channel~'应用宝' then '腾讯应用宝'
when channel~'纸片' then '纸片'
when channel~'团团' then '团团'
when channel~'335玩' then '335玩'
when channel~'朋克' then '朋克'
when channel~'安徽追游' then '安徽追游'
when channel~'冰火' then '冰火'
when channel~'心乐' then '心乐'
when channel LIKE '%华为%' OR
channel LIKE '%vivo%' OR
channel LIKE '%OPPO%' OR
channel LIKE '%魅族%' OR
channel LIKE '%努比亚%' OR
channel LIKE '%联想%' OR
channel LIKE '%酷派%' then '硬核联盟'
when channel~'9377' then '9377'
when channel~'智灵' then '智灵'
when channel~'掌游' then '掌游'
when channel~'上士' then '上士'
when channel~'攒趣' then '攒趣'
when channel~'掌玩' then '掌玩'
when channel~'贪玩' then '贪玩'
when channel~'wx'or channel~'WX'or channel~'微信' then '微信'
when channel~'公众号' then '公众号'
when channel~'qq' or channel~'QQ' then 'QQ'
when channel~'quick' then 'quick'
when channel~'七牛' then '七牛'
when channel~'霸气' then '霸气'
when channel~'xy' or channel~'XY' then 'XY'
when channel~'芝麻互娱' then '芝麻互娱'
when channel~'龙翔' then '龙翔'
when channel~'布咕' then '布咕'
when channel~'小柠互娱' then '小柠互娱'
when channel~'春秋玩' then '春秋玩'
when channel~'欢喜时代' then '欢喜时代'
when channel~'上游' then '上游'
when channel~'倾程' then '倾程'
when channel~'绿洲' then '绿洲'
when channel~'雷电' then '雷电'
when channel~'点点' then '点点'
when channel~'小七' then '小七'
when channel~'瓜玩' then '瓜玩'
when channel~'艺云' then '艺云'
when channel~'冠游' then '冠游'
when channel~'玄藏' then '玄藏'
when channel~'羽龙' then '羽龙'
when channel~'星云' then '星云'
when channel~'爱尚游' then '爱尚游'
when channel~'昊玩' then '昊玩'
when channel~'8酷' then '8酷'
when channel~'迅玩' then '迅玩'
when channel~'星游' then '星游'
when channel~'小米' then '小米'
when channel~'趣城' then '趣城'
when channel~'诺游' then '诺游'
when channel~'洛谷' then '洛谷'
when channel~'司墨' then '司墨'
when channel~'脚印' then '脚印'
when channel~'神游' then '神游'
when channel~'拓乐' then '拓乐'
when channel~'360' then '360'
when channel~'日昇' then '日昇'
when channel~'触点' then '触点'
when channel~'冠游' then '冠游'
when channel~'巴兔' then '巴兔'
when channel~'天纵' then '天纵'
when channel~'早游戏' then '早游戏'
when channel~'爱趣' then '爱趣'
when channel~'星楠祥' then '星楠祥'
when channel~'贪游' then '贪游'
when channel~'君游' then '君游'
when channel~'996直播间' then '996直播间'
when channel~'mumu' then 'mumu'
when channel~'吉祥' then '吉祥直播间'
when channel~'溪谷' then '溪谷'
when channel~'优谷' then '优谷'
when channel~'闪趣' then '闪趣'
when channel~'8酷' then '8酷'
when channel~'抖音' then '抖音'
when channel~'斗鱼' then '斗鱼'
when channel~'虎牙' then '虎牙'
when channel~'巨量' then '巨量'
when channel~'快手' then '快手'
when channel~'爱奇艺' then '爱奇艺'
when channel~'007' then '007'
when channel~'圣宏' then '圣宏'
when channel~'顺火' then '顺火'
when channel~'飞火' then '飞火'
when channel~'乐岛' then '乐岛'
when channel~'传柒' then '传柒'
when channel~'星际' then '星际'
when channel~'玖趣' then '玖趣'
when lower(channel)~'ku25' then 'ku25'
when channel~'8090' then '8090'
when lower(channel)~'appstore' then 'AppStore'
when channel~'欢娱' then '欢娱'
when channel~'逐梦' then '逐梦'
when channel~'兴动' then '兴动'
when channel~'3733' then '3733'
when channel~'第一游戏' then '第一游戏'
when channel~'公会' then '公会'
when channel~'欢娱' then '欢娱'
when channel~'335玩' then '335玩'
when lower(channel)~'4yx' then '4yx'
when channel~'37' then '37'
when channel~'开心' then '开心'
when lower(channel)~ 'ios' or channel~'苹果' then 'ios苹果端具体不详'
when channel~'触点' then '触点'
when channel~'游码' then '游码'
when lower(channel)~'45yx' then '45yx'
when channel~'巨量' then '巨量'
when channel~'小铃铛' then '小铃铛'
when channel~'2345' then '2345'
when channel~'梨子' then '梨子'
when channel~'麦游' then '麦游'
when channel~'群英' then '群英'
when channel~'阅文' then '阅文'
when lower(channel)~'kopo' then 'kopo'
when channel~'创启' then '创启'
when channel~'4366' then '4366'
when channel~'大楚' then '大楚'
when channel~'巅峰' then '巅峰'
when channel~'277' then '277'
when channel~'112233' then '112233'
when channel~'714' then '714'
when channel~'4399' then '4399'
when channel~'追忆' then '追忆'
when lower(channel)~'yy' then 'yy'
when channel~'588' then '588'
when channel~'八门' then '八门'
when lower(channel)~'pdd' then 'pdd'
when channel~'9917' then '9917'
when channel~'51517' then '51517'
when lower(channel)~'4yx' then '4yx'
when channel~'好汉' then '好汉'
when channel~'51' then '51'
when channel~'葫芦侠' then '葫芦侠'
when channel~'虫虫' then '虫虫'
when channel~'跃游' then '跃游'
when channel~'天天' then '天天'
when channel~'66' then '66'
when channel~'嘉禾' then '嘉禾'
when channel~'爱游' then '爱游'
when channel~'乐疯玩' then '乐疯玩'
when channel~'游戏饭' then '游戏饭'
else '其他' end as re_channel,
uniq(user_id) as mau
from public.ods_active_account t1
inner join
(
select id,name,bind_game_id
from public.gm_apply
where bind_game_type=1
) t2 on t1.appid=t2.id
where t1.ds BETWEEN '${bizmonth}' AND '${bizdate}'
group by 1,2,3
;

View File

@ -0,0 +1,529 @@
CREATE TABLE datasci.ads_996eco_index_coop_m (
index_type text,
data_month text,
coop text,
pay_cnt bigint,
pay_amount bigint,
mau bigint,
rt bigint,
device_type_new text,
act_num bigint,
reg_count bigint,
);
DELETE FROM datasci.ads_996eco_index_coop_m WHERE ds = '${month}';
--
WITH ga AS (
SELECT
id,
name,
CASE WHEN account IN ('wanxin996', 'qqq492864156','yueyou996') THEN '玩心'
WHEN account IN ('13234701199', 'xiongDiwan', 'xiongdi996', '996xiongdi', 'cly225522') THEN '春秋玩'
when account in ('tuantuan6400', 'whtuantuan', 'whzhangyou','whzhangyou1')then'安峰'
when account in ('Jinri', 'zhangqian996') THEN '掌玩'
when account in ('zlkj996') then '智灵'
WHEN account IN ('ssyy1') THEN '盈优'
WHEN account IN ('ky6709','wangsiqun') THEN '恺英'
WHEN account IN ('hzxs0375','diaobao1') THEN '勋双'
WHEN account IN ('nb1290733693', '9377yyeb', '9377syybyy') THEN '9377'
WHEN account IN ('longxiang', 'zhanxingbo', '18659080001') THEN '龙翔'
WHEN account IN ('13216396033', 'Zwzb2024', 'YP2024') THEN '玉盘'
WHEN account IN ('tanwangm', 'tanwan996', 'tw996hz99', 'tw996hz66', 'tanlang996', '15868405282', 'tanwanjx') then '贪玩'
WHEN account IN ('chongqu001','18968060998') and name ~ '【宠趣.*】|【87.*】' then '宠趣'
WHEN account IN ('youyi888','youyi999') and name ~ '【YY.*】|【游奕.*】' then '游奕'
WHEN account IN ('jinrui','huiqi996','996mailiang','HYXCX','masheng527') then '慧跃'
WHEN account in ('biqiwan') then '常州万趣'
WHEN account in ('nxn0310') then '成都星楠祥'
WHEN account in ('youxinhuyu') then '成都游鑫'
WHEN account in ('a9527cc') then '东莞起量'
WHEN account in ('yiwan123') then '赣州易玩'
WHEN account in ('gzyw6772') then '广州悦玩'
WHEN account in ('YL15102760231') then '海南岩岭'
WHEN account in ('145929L','hzqy9523') then '杭州乾赟'
WHEN account in ('simo123') then '杭州司墨'
WHEN account in ('zhaochengzhi') then '杭州速叶'
WHEN account in ('masheng527') then '杭州炫灿'
WHEN account in ('leijian4') then '湖北瓜玩'
WHEN account in ('jiangxicw2025') then '江西超网'
WHEN account in ('xc188164') then '江西热血'
WHEN account in ('zjzq3585') then '临沂好汉'
WHEN account in ('lezhuyou') then '青岛乐猪游'
WHEN account in ('quyou') then '厦门趣游'
WHEN account in ('jishijiayou') then '上海纪世嘉游'
WHEN account in ('mita') then '上海迷塔'
WHEN account in ('daimiaohudong') then '四川呆喵'
WHEN account in ('whqujie2025') then '武汉趣界云图'
WHEN account in ('qfyw2024996') then '武汉全方易维'
WHEN account in ('wjyx') then '武汉莴苣'
WHEN account in ('yansong') then '徐州木牛游马'
WHEN name ~ '【.*?联运' THEN REGEXP_REPLACE(name, '.*【(.*?)联运.*', '\1')
WHEN name ~ '【.*?】' THEN REGEXP_REPLACE(name, '.*【(.*?)】.*', '\1')
ELSE '其他' END AS co_oper_partner
FROM public.gm_apply
WHERE bind_type = 1 AND bind_game_type = 1
),
bt AS (
SELECT
na.user_id,
'盒子' AS box_tag
FROM public.ods_newly_account na
WHERE na.appid = '1015'
GROUP BY na.user_id, box_tag
),
po AS (
SELECT
appid,
ds,
user_id,
SUM(amount) AS pay_amount
FROM public.ods_payment_order
WHERE status = 1
AND ds::date BETWEEN '${bizmonth}' AND '${bizdate}'
GROUP BY 1, 2, 3
)
INSERT INTO
datasci.ads_996eco_index_coop_m (index_type,data_month,coop,pay_cnt,pay_amount)
SELECT
'pay' AS index_type,
'${month}' data_month,
COALESCE(bt.box_tag, ga.co_oper_partner) AS coop,
UNIQ(po.user_id) AS pay_cnt,
SUM(po.pay_amount) AS pay_amount
FROM po
INNER JOIN
ga ON po.appid = ga.id
LEFT JOIN
bt ON po.user_id = bt.user_id
GROUP BY 1,2,3
;
-- mau
WITH ga AS (
SELECT
id,
name,
CASE WHEN account IN ('wanxin996', 'qqq492864156','yueyou996') THEN '玩心'
WHEN account IN ('13234701199', 'xiongDiwan', 'xiongdi996', '996xiongdi', 'cly225522') THEN '春秋玩'
when account in ('tuantuan6400', 'whtuantuan', 'whzhangyou','whzhangyou1')then'安峰'
when account in ('Jinri', 'zhangqian996') THEN '掌玩'
when account in ('zlkj996') then '智灵'
WHEN account IN ('ssyy1') THEN '盈优'
WHEN account IN ('ky6709','wangsiqun') THEN '恺英'
WHEN account IN ('hzxs0375','diaobao1') THEN '勋双'
WHEN account IN ('nb1290733693', '9377yyeb', '9377syybyy') THEN '9377'
WHEN account IN ('longxiang', 'zhanxingbo', '18659080001') THEN '龙翔'
WHEN account IN ('13216396033', 'Zwzb2024', 'YP2024') THEN '玉盘'
WHEN account IN ('tanwangm', 'tanwan996', 'tw996hz99', 'tw996hz66', 'tanlang996', '15868405282', 'tanwanjx') then '贪玩'
WHEN account IN ('chongqu001','18968060998') and name ~ '【宠趣.*】|【87.*】' then '宠趣'
WHEN account IN ('youyi888','youyi999') and name ~ '【YY.*】|【游奕.*】' then '游奕'
WHEN account IN ('jinrui','huiqi996','996mailiang','HYXCX','masheng527') then '慧跃'
WHEN account in ('biqiwan') then '常州万趣'
WHEN account in ('nxn0310') then '成都星楠祥'
WHEN account in ('youxinhuyu') then '成都游鑫'
WHEN account in ('a9527cc') then '东莞起量'
WHEN account in ('yiwan123') then '赣州易玩'
WHEN account in ('gzyw6772') then '广州悦玩'
WHEN account in ('YL15102760231') then '海南岩岭'
WHEN account in ('145929L','hzqy9523') then '杭州乾赟'
WHEN account in ('simo123') then '杭州司墨'
WHEN account in ('zhaochengzhi') then '杭州速叶'
WHEN account in ('masheng527') then '杭州炫灿'
WHEN account in ('leijian4') then '湖北瓜玩'
WHEN account in ('jiangxicw2025') then '江西超网'
WHEN account in ('xc188164') then '江西热血'
WHEN account in ('zjzq3585') then '临沂好汉'
WHEN account in ('lezhuyou') then '青岛乐猪游'
WHEN account in ('quyou') then '厦门趣游'
WHEN account in ('jishijiayou') then '上海纪世嘉游'
WHEN account in ('mita') then '上海迷塔'
WHEN account in ('daimiaohudong') then '四川呆喵'
WHEN account in ('whqujie2025') then '武汉趣界云图'
WHEN account in ('qfyw2024996') then '武汉全方易维'
WHEN account in ('wjyx') then '武汉莴苣'
WHEN account in ('yansong') then '徐州木牛游马'
WHEN name ~ '【.*?联运' THEN REGEXP_REPLACE(name, '.*【(.*?)联运.*', '\1')
WHEN name ~ '【.*?】' THEN REGEXP_REPLACE(name, '.*【(.*?)】.*', '\1')
ELSE '其他' END AS co_oper_partner
FROM public.gm_apply
WHERE bind_type = 1 AND bind_game_type = 1
),
bt AS (
SELECT
na.user_id,
'盒子' AS box_tag
FROM public.ods_newly_account na
WHERE na.appid = '1015'
GROUP BY na.user_id, box_tag
),
aa AS (
SELECT
appid,
ds,
user_id
FROM public.ods_active_account
WHERE ds BETWEEN '${hisdate}' AND '${bizdate}'
GROUP BY 1, 2, 3
)
INSERT INTO
datasci.ads_996eco_index_coop_m (index_type,data_month,coop,mau)
SELECT
'mau' index_type,
'${month}' data_month,
COALESCE(bt.box_tag, ga.co_oper_partner) AS coop,
UNIQ(aa.user_id) AS mau
FROM aa
INNER JOIN
ga ON aa.appid = ga.id
LEFT JOIN
bt ON aa.user_id = bt.user_id
GROUP BY 1,2,3;
-- Referral Traffic
with tmp_first_reg as (
select acc.gm_id,gm.account,acc.app_id,gm.app_name, acc.user_id,acc.event_time as plt_reg_time,acc.ds,
CASE WHEN gm.account IN ('wanxin996', 'qqq492864156','yueyou996') THEN '玩心'
WHEN gm.account IN ('13234701199', 'xiongDiwan', 'xiongdi996', '996xiongdi', 'cly225522') THEN '春秋玩'
when gm.account in ('tuantuan6400', 'whtuantuan', 'whzhangyou','whzhangyou1')then'安峰'
when gm.account in ('Jinri', 'zhangqian996') THEN '掌玩'
when gm.account in ('zlkj996') then '智灵'
WHEN gm.account IN ('ssyy1') THEN '盈优'
WHEN gm.account IN ('ky6709','wangsiqun') THEN '恺英'
WHEN gm.account IN ('hzxs0375','diaobao1') THEN '勋双'
WHEN gm.account IN ('nb1290733693', '9377yyeb', '9377syybyy') THEN '9377'
WHEN gm.account IN ('longxiang', 'zhanxingbo', '18659080001') THEN '龙翔'
WHEN gm.account IN ('13216396033', 'Zwzb2024', 'YP2024') THEN '玉盘'
WHEN gm.account IN ('tanwangm', 'tanwan996', 'tw996hz99', 'tw996hz66', 'tanlang996', '15868405282', 'tanwanjx') then '贪玩'
WHEN gm.account IN ('chongqu001','18968060998') and gm.app_name ~ '【宠趣.*】|【87.*】' then '宠趣'
WHEN gm.account IN ('youyi888','youyi999') and gm.app_name ~ '【YY.*】|【游奕.*】' then '游奕'
WHEN gm.account IN ('jinrui','huiqi996','996mailiang','HYXCX','masheng527') then '慧跃'
WHEN gm.account in ('biqiwan') then '常州万趣'
WHEN gm.account in ('nxn0310') then '成都星楠祥'
WHEN gm.account in ('youxinhuyu') then '成都游鑫'
WHEN gm.account in ('a9527cc') then '东莞起量'
WHEN gm.account in ('yiwan123') then '赣州易玩'
WHEN gm.account in ('gzyw6772') then '广州悦玩'
WHEN gm.account in ('YL15102760231') then '海南岩岭'
WHEN gm.account in ('145929L','hzqy9523') then '杭州乾赟'
WHEN gm.account in ('simo123') then '杭州司墨'
WHEN gm.account in ('zhaochengzhi') then '杭州速叶'
WHEN gm.account in ('masheng527') then '杭州炫灿'
WHEN gm.account in ('leijian4') then '湖北瓜玩'
WHEN gm.account in ('jiangxicw2025') then '江西超网'
WHEN gm.account in ('xc188164') then '江西热血'
WHEN gm.account in ('zjzq3585') then '临沂好汉'
WHEN gm.account in ('lezhuyou') then '青岛乐猪游'
WHEN gm.account in ('quyou') then '厦门趣游'
WHEN gm.account in ('jishijiayou') then '上海纪世嘉游'
WHEN gm.account in ('mita') then '上海迷塔'
WHEN gm.account in ('daimiaohudong') then '四川呆喵'
WHEN gm.account in ('whqujie2025') then '武汉趣界云图'
WHEN gm.account in ('qfyw2024996') then '武汉全方易维'
WHEN gm.account in ('wjyx') then '武汉莴苣'
WHEN gm.account in ('yansong') then '徐州木牛游马'
WHEN gm.account in ('zjh641391114') then '延边八七互娱'
when gm.app_name ~ '【.*?联运' then REGEXP_REPLACE(gm.app_name, '.*【(.*?)联运.*', '\1')
when gm.app_name !~ '【.*?联运' and gm.app_name ~ '.*【(.*?)】.*' then REGEXP_REPLACE(gm.app_name, '.*【(.*?)】.*', '\1')
when user_flag='盒子用户' and (acc.app_id='1015' or channel~'996box' or sub_channel is not null) then '盒子'
when gm.opr_name_abbr is not null then gm.opr_name_abbr
else '其他' --- concat(gm.opr_name_abbr,' (独立)')
end AS co_oper_partner,
--case when gm.app_name ~ '【.*?联运' then 1 else 0 end coper_flag,
case when channel~'996box|2046' then '盒子'
when channel~'ai6' then 'ai6'
when channel~'玩心' then '玩心'
when channel~'应用宝' then '应用宝'
when channel~'纸片' then '纸片'
when channel~'团团' then '团团'
when channel~'335玩' then '335玩'
when channel~'朋克' then '朋克'
when channel~'安徽追游' then '安徽追游'
when channel~'冰火' then '冰火'
when channel~'心乐' then '心乐'
when channel ~*'华为|vivo|oppo|魅族|努比亚|联想|酷派|硬核联盟' then '硬核联盟'
when channel~'9377' then '9377'
when channel~'智灵' then '智灵'
when channel~'掌游' then '掌游'
when channel~'上士' then '上士'
when channel~'攒趣' then '攒趣'
when channel~'掌玩' then '掌玩'
when channel~'贪玩' then '贪玩'
when channel~'wx'or channel~'WX'or channel~'微信' then '微信'
when channel~'公众号' then '公众号'
when channel~'qq' or channel~'QQ' then 'QQ'
--when channel~'quick' then 'quick'
when channel~'七牛' then '七牛'
when channel~'霸气' then '霸气'
when channel~'xy' or channel~'XY' then 'XY'
when channel~'芝麻互娱' then '芝麻互娱'
when channel~'龙翔' then '龙翔'
when channel~'布咕' then '布咕'
when channel~'小柠互娱' then '小柠互娱'
when channel~'春秋玩' then '春秋玩'
when channel~'欢喜时代' then '欢喜时代'
when channel~'上游' then '上游'
when channel~'倾程' then '倾程'
when channel~'绿洲' then '绿洲'
when channel~'雷电' then '雷电'
when channel~'点点' then '点点'
when channel~'小七' then '小七'
when channel~'瓜玩' then '瓜玩'
when channel~'艺云' then '艺云'
when channel~'冠游' then '冠游'
when channel~'玄藏' then '玄藏'
when channel~'羽龙' then '羽龙'
when channel~'星云' then '星云'
when channel~'爱尚游' then '爱尚游'
when channel~'昊玩' then '昊玩'
when channel~'8酷' then '8酷'
when channel~'迅玩' then '迅玩'
when channel~'星游' then '星游'
when channel~'小米' then '小米'
when channel~'趣城' then '趣城'
when channel~'诺游' then '诺游'
when channel~'洛谷' then '洛谷'
when channel~'司墨' then '司墨'
when channel~'脚印' then '脚印'
when channel~'神游' then '神游'
when channel~'拓乐' then '拓乐'
when channel~'360' then '360'
when channel~'日昇' then '日昇'
when channel~'触点' then '触点'
when channel~'冠游' then '冠游'
when channel~'巴兔' then '巴兔'
when channel~'天纵' then '天纵'
when channel~'早游戏' then '早游戏'
when channel~'爱趣' then '爱趣'
when channel~'星楠祥' then '星楠祥'
when channel~'贪游' then '贪游'
when channel~'君游' then '君游'
when channel~'996直播间' then '996直播间'
when channel~'mumu' then 'mumu'
when channel~'吉祥' then '吉祥直播间'
when channel~'溪谷' then '溪谷'
when channel~'优谷' then '优谷'
when channel~'闪趣' then '闪趣'
when channel~'8酷' then '8酷'
when channel~'抖音' then '抖音'
when channel~'斗鱼' then '斗鱼'
when channel~'虎牙' then '虎牙'
when channel~'巨量' then '巨量'
when channel~'快手' then '快手'
when channel~'爱奇艺' then '爱奇艺'
when channel~'007' then '007'
when channel~'圣宏' then '圣宏'
when channel~'顺火' then '顺火'
when channel~'飞火' then '飞火'
when channel~'乐岛' then '乐岛'
when channel~'传柒' then '传柒'
when channel~'星际' then '星际'
when channel~'玖趣' then '玖趣'
when channel~*'ku25' then 'ku25'
when channel~'8090' then '8090'
when channel~*'appstore' then 'AppStore'
when channel~'欢娱' then '欢娱'
when channel~'逐梦' then '逐梦'
when channel~'兴动' then '兴动'
when channel~'3733' then '3733'
when channel~'第一游戏' then '第一游戏'
when channel~'公会' then '公会'
when channel~'欢娱' then '欢娱'
when channel~'335玩' then '335玩'
when channel~*'4yx' then '4yx'
when channel~'37' then '37'
when channel~'开心' then '开心'
when channel~*'ios' or channel~'苹果' then 'ios苹果端具体不详'
when channel~'触点' then '触点'
when channel~'游码' then '游码'
when channel~*'45yx' then '45yx'
when channel~'巨量' then '巨量'
when channel~'小铃铛' then '小铃铛'
when channel~'2345' then '2345'
when channel~'梨子' then '梨子'
when channel~'麦游' then '麦游'
when channel~'群英' then '群英'
when channel~'阅文' then '阅文'
when channel~*'kopo' then 'kopo'
when channel~'创启' then '创启'
when channel~'4366' then '4366'
when channel~'大楚' then '大楚'
when channel~'巅峰' then '巅峰'
when channel~'277' then '277'
when channel~'112233' then '112233'
when channel~'714' then '714'
when channel~'4399' then '4399'
when channel~'追忆' then '追忆'
when channel~*'yy' then 'yy'
when channel~'588' then '588'
when channel~'八门' then '八门'
when channel~*'pdd' then 'pdd'
when channel~'9917' then '9917'
when channel~'51517' then '51517'
when channel~*'4yx' then '4yx'
when channel~'好汉' then '好汉'
when channel~'51' then '51'
when channel~'葫芦侠' then '葫芦侠'
when channel~'虫虫' then '虫虫'
when channel~'跃游' then '跃游'
when channel~'天天' then '天天'
when channel~'66' then '66'
when channel~'嘉禾' then '嘉禾'
when channel~'爱游' then '爱游'
when channel~'乐疯玩' then '乐疯玩'
when channel~'游戏饭' then '游戏饭'
when channel~'百度' then '百度'
when channel~'UC' then 'UC'
when channel~'网易' then '网易'
when channel~'启示科创' then '启示科创'
when channel~'抖音' then '抖音'
when channel~'搜狗' then '搜狗'
when channel~'移端' then '移端'
when channel~'千易' then '千易'
when channel~'应用市场' then '应用市场'
when channel~'360' then '360'
when channel~'07073' then '07073'
when channel~'巨鳄' then '巨鳄'
when channel~'星光斗聚' then '星光斗聚'
when channel~'广点通' then '广点通'
when channel~'热云' then '热云'
when channel~'云刺' then '云刺'
when channel~'财泰' then '财泰'
when channel~'沈阳阅览' then '沈阳阅览'
when channel~'新义' then '新义'
when channel~'钰玺公众号' then '钰玺公众号'
when channel~'蜀游' then '蜀游'
when channel~'月象' then '月象'
when channel~'云境' then '云境'
when channel~'小米' then '小米'
when channel~*'sigmob' then 'Sigmob'
when channel~'睿初' then '睿初'
when channel~'豌豆荚' then '豌豆荚'
when channel~'橙益' then '橙益'
when channel~'汉鸣' then '汉鸣'
when channel~'因特云' then '因特云'
when channel~'奕浪' then '奕浪'
when channel~'鸿扬' then '鸿扬'
when channel~'新宸睿' then '新宸睿'
when channel~'翊宸' then '翊宸'
when channel~'巨麦' then '巨麦'
when channel~'2345' then '2345'
when channel~'烈火封神网页' then '烈火封神网页'
when channel~'北星' then '北星'
when channel~'承宇齐光' then '承宇齐光'
when channel~'微信' then '微信'
when channel~'拾元立方' then '拾元立方'
when channel~'头条' then '头条'
when channel~'洛阳兰奇' then '洛阳兰奇'
when channel~'金领' then '金领'
when channel~'云游怀旧服' then '云游怀旧服'
when channel~'自投' then '自投'
when channel~'陕西米效' then '陕西米效'
when channel~'芈兔兔' then '芈兔兔'
when channel~'辣条山海传' then '辣条山海传'
when channel~'钢蹦罗刹海超神器' then '钢蹦罗刹海超神器'
when channel~'猫猫上古火龙' then '猫猫上古火龙'
when channel~'苍云铭文沉默' then '苍云铭文沉默'
when channel~'蓝奏' then '蓝奏'
when channel~'三星' then '三星'
when channel~'上海堡英' then '上海堡英'
when channel~'短信' then '短信'
when channel~'朋友圈' then '微信'
when channel~'996争霸赛' then '996争霸赛'
when channel~'华联' then '华联'
when channel~'必应' then '必应'
when channel~'野草' then '野草'
when channel~'微博' then '微博'
when channel~'依目' then '依目'
when channel~'腾讯' then '腾讯'
when channel~'去玩诸神沉默' then '去玩诸神沉默'
when channel~'骏风古龙沉默' then '骏风古龙沉默'
when channel~'去玩影月沉默' then '去玩影月沉默'
when channel~'丰巢' then '丰巢'
when channel~'云想冰雪' then '云想冰雪'
when channel~'龙云至尊无限刀' then '龙云至尊无限刀'
when channel~'蔚隆私域' then '蔚隆私域'
when channel~'云游小极品' then '云游小极品'
when channel~'珈蓝沉默' then '珈蓝沉默'
when channel~'灵霜传奇' then '灵霜传奇'
when channel~*'pp助手' then 'pp助手'
when channel~'西瓜沉默超超超变' then '西瓜沉默超超超变'
when channel~'白马火龙' then '白马火龙'
when channel~'好看' then '好看'
when channel~'戎马传奇' then '戎马传奇'
when channel~'烛龙相逢沉默' then '烛龙相逢沉默'
when channel~'99交易行' then '99交易行'
when channel~'洪量' then '洪量'
when channel~'小说定制包' then '小说定制包'
when channel~'传奇手游' then '传奇手游'
when channel~'九天传奇' then '九天传奇'
when channel~'猛虎传奇3' then '猛虎传奇3'
when channel~'巨灵传奇3' then '巨灵传奇3'
when channel~'惊天传奇4' then '惊天传奇4'
when channel~'墨府传奇4' then '墨府传奇4'
when channel~'盛游火龙' then '盛游火龙'
when channel~'中天传奇181' then '中天传奇181'
when channel~'中天龙脉大陆' then '中天龙脉大陆'
when channel~'潜龙传奇' then '潜龙传奇'
when channel~'飞轩火龙' then '飞轩火龙'
when channel~'净土沉默复古版' then '净土沉默复古版'
when channel~'锋战传奇' then '锋战传奇'
when channel~'归龙火龙' then '归龙火龙'
when channel~'大楚传奇' then '大楚传奇'
when channel~'春秋传奇' then '春秋传奇'
when channel~'意意180轻变' then '意意180轻变'
when channel~'巨灵传奇4怀旧版' then '巨灵传奇4怀旧版'
when channel~'青花传奇' then '青花传奇'
when channel~'流失用户回归包' then '流失用户回归包'
when channel~'昆山创游' then '昆山创游'
when channel~*'ubx' then 'UBX'
when channel~'木之无尽沉默' then '木之无尽沉默'
when channel~'品动灯火' then '品动灯火'
when channel~'宗师传奇' then '宗师传奇'
when channel~'小说排名公示' then '小说排名公示'
when channel~'北京雨悦美通' then '北京雨悦美通'
when channel~*'kook' then 'kook'
when channel~'尚聚专属无限刀' then '尚聚专属无限刀'
when channel~'优酷' then '优酷'
else '其他' end as channel
FROM datasci.dws_plt_newly_account_d acc
-- reg_account acc
-- inner join (select user_id,min(event_time) as event_time_min
-- from reg_account
-- group by user_id
-- ) mi ---从玩家的众多游戏记录中选取最早的一条
-- on acc.user_id=mi.user_id and acc.event_time=mi.event_time_min
inner join (SELECT id::text as app_id,
name as app_name,
app.account,
inf.name_abbr as opr_name_abbr,
bind_game_id,
bind_game_type ---1 : , 2: , 3 , 4:3
FROM public.gm_apply app -- 传奇游戏
left join (select account,name_abbr from public.dim_gm_info
---where game_type='传奇'
) inf
on app.account=inf.account
--or id=1015
) gm
on acc.app_id=gm.app_id
where acc.ds BETWEEN '${hisdate}' AND '${bizdate}'
)
INSERT INTO
datasci.ads_996eco_index_coop_m (index_type,data_month,coop,rt)
SELECT
'rt' index_type,
'${month}' data_month,
co_oper_partner coop,
uniq (user_id) AS rt
FROM
tmp_first_reg
GROUP BY
1,2,3

View File

@ -0,0 +1,120 @@
CREATE TABLE datasci.ads_996eco_index_device_m (
index_type text,
data_month text,
re_device_type text,
act_cnt bigint,
pay_cnt bigint,
pay_amount bigint,
mau bigint,
act_num bigint,
reg_count bigint,
);
DELETE FROM datasci.ads_996eco_index_device_m WHERE ds = '${month}';
-- 每月付费
WITH ga AS (
SELECT
id,
name
FROM public.gm_apply
WHERE bind_type = 1 AND bind_game_type = 1
)
,
aa AS (
SELECT
'${month}' data_month,
case when device_type ~*'h5' then 'H5'
when device_type ~*'pc' then 'PC'
when device_type ~*'ios' then 'IOS'
when device_type ~*'mac' then 'mac'
when device_type ~*'android' then 'Android'
when device_type ~*'harmony' then '鸿蒙'
else '其他' end AS re_device_type,
UNIQ(user_id) act_cnt
FROM
public.ods_active_account aa
INNER JOIN
ga ga ON aa.appid = ga.id
WHERE ds BETWEEN '${bizmonth}' AND '${bizdate}'
GROUP BY 1,2
),
po AS (
SELECT
'${month}' data_month,
case when device_type ~*'h5' then 'H5'
when device_type ~*'pc' then 'PC'
when device_type ~*'ios' then 'IOS'
when device_type ~*'mac' then 'mac'
when device_type ~*'android' then 'Android'
when device_type ~*'harmony' then '鸿蒙'
else '其他' end AS re_device_type,
UNIQ(po.user_id) pay_cnt,
SUM(po.amount) pay_amount
FROM
public.ods_payment_order po
INNER JOIN
ga ga ON po.appid = ga.id
WHERE ds BETWEEN '${bizmonth}' AND '${bizdate}'
GROUP BY 1,2
)
INSERT INTO
datasci.ads_996eco_index_device_m (index_type,data_month,re_device_type,act_cnt,pay_cnt,pay_amount)
SELECT
'pay' index_type,
t1.data_month AS data_month,
t1.re_device_type,
t1.act_cnt AS act_cnt,
t2.pay_cnt AS pay_cnt,
t2.pay_amount AS pay_amount
FROM aa t1
LEFT JOIN
po t2 ON t1.data_month = t2.data_month and t1.re_device_type = t2.re_device_type
;
INSERT INTO
datasci.ads_996eco_index_device_m (index_type,data_month,re_device_type,mau)
select
'mau' index_type,
'${month}' data_month,
case when lower(t1.device_type)~'h5' then 'H5'
when lower(t1.device_type)~'pc' then 'PC'
when lower(t1.device_type)~'ios' then 'IOS'
else t1.device_type end as re_device_type,
uniq(user_id) as mau
from public.ods_active_account t1
inner join
(
select id,name,bind_game_id
from public.gm_apply
where bind_game_type=1
) t2 on t1.appid=t2.id
where t1.ds BETWEEN '${bizmonth}' AND '${bizdate}'
group by 1,2,3
;
INSERT INTO
datasci.ads_996eco_index_device_m (index_type,data_month,re_device_type,mau,device_type)
select
'device-type-mau' index_type,
'${month}' data_month,
case when lower(t1.device_type)~'h5' then 'H5'
when lower(t1.device_type)~'pc' then 'PC'
when lower(t1.device_type)~'ios' then 'IOS'
else t1.device_type end as re_device_type,
uniq(user_id) as mau,
t1.device_type
from public.ods_active_account t1
inner join
(
select id,name,bind_game_id
from public.gm_apply
where bind_game_type=1
) t2 on t1.appid=t2.id
where t1.ds BETWEEN '${bizmonth}' AND '${bizdate}'
group by 1,2,3,5
;

View File

@ -0,0 +1,177 @@
CREATE TABLE datasci.ads_996eco_index_role_m (
index_type text,
data_month text,
tg_play text,
tg_ver text,
tg_value text,
tg_job text,
tg_feature text,
act_num bigint,
acc_count bigint,
pay_cnt bigint,
pay_amount bigint,
);
DELETE FROM datasci.ads_996eco_index_channel_m WHERE ds = '${month}';
INSERT INTO
datasci.ads_996eco_index_role_m (index_type,data_month,tg_play,tg_ver,tg_value,tg_job,tg_feature,act_num)
select
'mau' index_type,
'${month}' AS data_month,
tg_play.tag as tg_play,tg_ver.tag as tg_ver,tg_value.tag as tg_value,tg_job.tag as tg_job,tg_feature.tag as tg_feature,
uniq(user_id) as act_num
from public.ods_active_account t1
inner join
(
select id,name,bind_game_id
from public.gm_apply
where bind_game_type=1
) t2 on t1.appid=t2.id
left outer join
(select game_id,tag from public.game_tags where tag in ('神器','复古','沉默','火龙','合击','迷失','小极品','大极品','二合一','铭文','冰雪','宠物','战神','暗黑','元素','忘忧','BUFF','天罡'))tg_play
on t2.bind_game_id=tg_play.game_id
left outer join
(select game_id,tag from public.game_tags where tag in ('1.70','1.76','1.80','1.85','1.95'))tg_ver
on t2.bind_game_id=tg_ver.game_id
left outer join
(select game_id,tag from public.game_tags where tag in ('经典','微变','中变','超变'))tg_value
on t2.bind_game_id=tg_value.game_id
left outer join
(select game_id,tag from public.game_tags where tag in ('单职业','三职业','多职业'))tg_job
on t2.bind_game_id=tg_job.game_id
left outer join
(select game_id,tag from public.game_tags where tag in ('3D','开服1年','开服2年','开服3年','开服4年'))tg_feature
on t2.bind_game_id=tg_feature.game_id
where t1.ds BETWEEN '${hisdate}' AND '${bizdate}'
group by
1,2,3,4,5,6,7
;
-- reg
INSERT INTO
datasci.ads_996eco_index_role_m (index_type,data_month,tg_play,acc_count)
select
'reg' index_type,
'${month}' AS data_month,
case when tg_play.tag is null then '未知' else tg_play.tag end as tg_play,
uniq(mi.user_id) as acc_count
from public.ods_newly_account acc
inner join (select user_id,min(event_time) as event_time_min
from public.ods_newly_account acc
inner join (select * from public.gm_apply
WHERE bind_game_type = 1 -- 传奇游戏
) app
on acc.appid=app.id
group by user_id
) mi ---
on acc.user_id=mi.user_id and acc.event_time=mi.event_time_min
inner join (SELECT id as app_id,
name as app_name,
bind_game_id,
bind_game_type ---1 : , 2: , 33
FROM public.gm_apply
WHERE bind_type = 1 -- 默认应用
-- AND bind_game_type = 1 -- 传奇游戏
) gm
on acc.appid=gm.app_id
left outer join
(select game_id,tag from public.game_tags where tag in ('神器','复古','沉默','火龙','合击','迷失','小极品','大极品','二合一','铭文','冰雪','宠物','战神','暗黑','元素','忘忧','BUFF','天罡'))tg_play
on gm.bind_game_id=tg_play.game_id
where acc.ds BETWEEN '${hisdate}' AND '${bizdate}'
group by 1,2,3
;
--
WITH ga AS (
SELECT
id,
bind_game_id
FROM public.gm_apply
WHERE bind_type = 1 AND bind_game_type = 1
),
tg AS (
SELECT
game_id,
string_agg(DISTINCT CASE WHEN tag in ('神器','复古','沉默','火龙','合击','迷失','小极品','大极品','二合一','铭文','冰雪','宠物','战神','暗黑','元素','忘忧','BUFF','天罡') THEN tag ELSE NULL END,',') AS tg_play,
string_agg(DISTINCT CASE WHEN tag in ('1.70','1.76','1.80','1.85','1.95')THEN tag ELSE NULL END, ',') AS ver_tag,
string_agg(DISTINCT CASE WHEN tag in ('经典','微变','中变','超变') THEN tag ELSE NULL END,',') AS value_tag,
string_agg(DISTINCT CASE WHEN tag in ('单职业','三职业','多职业') THEN tag ELSE NULL END,',') AS job_tag,
string_agg(DISTINCT CASE WHEN tag in ('3D','开服1年','开服2年','开服3年','开服4年') THEN tag ELSE NULL END,',') AS feature_tag
FROM public.game_tags
GROUP BY game_id
),
po AS (
SELECT
appid,
ds,
user_id,
SUM(amount) AS pay_amount
FROM public.ods_payment_order
WHERE status = 1
AND ds::date BETWEEN '${hisdate}' AND '${bizdate}'
GROUP BY 1, 2, 3
)
INSERT INTO
datasci.ads_996eco_index_role_m (index_type,data_month,tg_play,pay_cnt,pay_amount)
SELECT
'pay' index_type,
'${month}' AS data_month,
tg.tg_play,
UNIQ(po.user_id) AS pay_cnt,
SUM(po.pay_amount) AS pay_amount
FROM po
INNER JOIN
ga ON po.appid = ga.id
LEFT JOIN
tg ON ga.bind_game_id = tg.game_id
GROUP BY 1,2,3
;
--
WITH ga AS (
SELECT
id,
bind_game_id
FROM public.gm_apply
WHERE bind_type = 1 AND bind_game_type = 1
),
tg AS (
SELECT
game_id,
string_agg(DISTINCT CASE WHEN tag in ('神器','复古','沉默','火龙','合击','迷失','小极品','大极品','二合一','铭文','冰雪','宠物','战神','暗黑','元素','忘忧','BUFF','天罡') THEN tag ELSE NULL END,',') AS tg_play,
string_agg(DISTINCT CASE WHEN tag in ('1.70','1.76','1.80','1.85','1.95')THEN tag ELSE NULL END, ',') AS ver_tag,
string_agg(DISTINCT CASE WHEN tag in ('经典','微变','中变','超变') THEN tag ELSE NULL END,',') AS value_tag,
string_agg(DISTINCT CASE WHEN tag in ('单职业','三职业','多职业') THEN tag ELSE NULL END,',') AS job_tag,
string_agg(DISTINCT CASE WHEN tag in ('3D','开服1年','开服2年','开服3年','开服4年') THEN tag ELSE NULL END,',') AS feature_tag
FROM public.game_tags
GROUP BY game_id
),
aa AS (
SELECT
appid,
ds,
user_id
FROM public.ods_active_account
WHERE ds BETWEEN '${hisdate}' AND '${bizdate}'
GROUP BY 1, 2, 3
)
INSERT INTO
datasci.ads_996eco_index_role_m (index_type,data_month,tg_play,acc_count)
SELECT
'tg-mau' index_type,
'${month}' AS data_month,
tg.tg_play,
UNIQ(aa.user_id) AS acc_count
FROM aa
INNER JOIN
ga ON aa.appid = ga.id
LEFT JOIN
tg ON ga.bind_game_id = tg.game_id
GROUP BY 1,2,3
;

View File

@ -0,0 +1,26 @@
# 角色
你是一个SQL专家或数据分析师,根据检索到
以及用户输入的
# 需求
生成对应的查询sql,sql必须经过严格的校验。
# 硬性要求
1.只能使用检索到的表字段,数据库查询语句尽可能简单,不需要过分解读写出复杂sql,多表查询需要注意传递表格有多少,如果整个内容只有一张表格,不要使用多表
2.确保pgSQL语法兼容,其中如果传递条件是文字或者字符串,默认使用模糊搜索,模糊搜索的格式是: 字段 like “%值%”
3.仅输出最终结果sql语句的txt文本,不要加任何信息,
4.禁止中间过程输出
## 角色
你是数据分析大师和总结者##任务
你可以结合用户的问题和从数据库查询到的结果,整合提炼后用精准合适的自然语言回复用户
## 输出
1.若用户只是查询数据,则提炼后直接回复数据内容即可
2.若用户需要你分析数据,则你可以结合数据给出专业的分析内容
# 任务
把数据库数据转化为表格类型的markdown文本内容把表头翻译为中文
# 输出
只输出转化后的表格类型的markdown,不要"markdown\n""等语言标签只输出标准的markdwon表格

View File

View File

@ -0,0 +1,6 @@
# 角色
你是一个文字提炼专家
# 任务
负责把用户的查询数据需求进行提炼,总结.抓取关键的数据查询文字,去除掉和数据查询的无关内容,比如生成图表,生成Excel,生成表单等和数据查询无关的内容,只保留提炼查询数据的文字
# 输出
只输出你提炼后的结果,无需其他言语

13
other/1.md Normal file
View File

@ -0,0 +1,13 @@
1.需求调研(1.和产品一起对接业务.了解需求点 2.领导根据公司的发展决定要做某一块的东西)
2.技术选型(1.公司现有的技术栈 2.云服务or本地服务 3.成本预估)
3.设计原型和接口文档
1.设计表结构 2.对接业务需求和确定产品效果兜底
https://lqc33t.yuque.com/lqc33t/npg9vh/uhsyk1
https://kkd7nv.axshare.com/?id=ejq4yx&p=%E5%AE%A2%E8%AF%89%E7%9C%8B%E6%9D%BF
4.开发根据需求拆分模块并行开发(引入git,云效,swagger)
1.写业务逻辑 2.提交发版 3.测试 (通过打回修改后提交再测试通过)
5.项目部署
linux docker k8s nginx 数据库 中间件
6.正式上线
公网ip 域名 (小程序更复杂)

1
sql笔记/sql.sql Normal file
View File

@ -0,0 +1 @@
ALTER TABLE ads.date_table5 RENAME TO dim_date_table;