Commit 9573f07c authored by 魏艺敏's avatar 魏艺敏

update codes

parent 2b525fa9
--美购详情页的分发
SELECT `日期`,`设备类型`,`活跃类型`,`渠道`
,`美购详情页浏览pv`
,(`加购物车点击pv`+`评价列表页点击pv`+`立即支付点击pv`+`私信及电话咨询pv` +`选择美购项目点击pv`
+`机构主页点击pv`+`机构的其他美购点击pv`+`推荐美购点击pv`+`收藏点击pv`
+`右上角购物车点击pv`+`医生主页点击pv`+`分享点击pv`+`机构导航点击pv`) as `美购详情页分发pv加总`
,concat(round((`加购物车点击pv`+`评价列表页点击pv`+`立即支付点击pv`+`私信及电话咨询pv` +`选择美购项目点击pv`
+`机构主页点击pv`+`机构的其他美购点击pv`+`推荐美购点击pv`+`收藏点击pv`
+`右上角购物车点击pv`+`医生主页点击pv`+`分享点击pv`+`机构导航点击pv`)/`美购详情页浏览pv`*100,2),'%') as `美购详情页分发pv占比加总`
,`加购物车点击pv`
,concat(round(`加购物车点击pv`/`美购详情页浏览pv`*100,2),'%') as `加购物车点击pv占比`
,`评价列表页点击pv`
,concat(round(`评价列表页点击pv`/`美购详情页浏览pv`*100,2),'%') as `评价列表页点击pv占比`
,`立即支付点击pv`
,concat(round(`立即支付点击pv`/`美购详情页浏览pv`*100,2),'%') as `立即支付点击pv占比`
,`私信及电话咨询pv`
,concat(round(`私信及电话咨询pv`/`美购详情页浏览pv`*100,2),'%') as `私信及电话咨询pv占比`
,`选择美购项目点击pv`
,concat(round(`选择美购项目点击pv`/`美购详情页浏览pv`*100,2),'%') as `选择美购项目点击pv占比`
,`机构主页点击pv`
,concat(round(`机构主页点击pv`/`美购详情页浏览pv`*100,2),'%') as `机构主页点击pv占比`
,`机构的其他美购点击pv`
,concat(round(`机构的其他美购点击pv`/`美购详情页浏览pv`*100,2),'%') as `机构的其他美购点击pv占比`
,`推荐美购点击pv`
,concat(round(`推荐美购点击pv`/`美购详情页浏览pv`*100,2),'%') as `推荐美购点击pv占比`
,`收藏点击pv`
,concat(round(`收藏点击pv`/`美购详情页浏览pv`*100,2),'%') as `收藏点击pv占比`
,`右上角购物车点击pv`
,concat(round(`右上角购物车点击pv`/`美购详情页浏览pv`*100,2),'%') as `右上角购物车点击pv占比`
,`医生主页点击pv`
,concat(round(`医生主页点击pv`/`美购详情页浏览pv`*100,2),'%') as `医生主页点击pv占比`
,`分享点击pv`
,concat(round(`分享点击pv`/`美购详情页浏览pv`*100,2),'%') as `分享点击pv占比`
,`机构导航点击pv`
,concat(round(`机构导航点击pv`/`美购详情页浏览pv`*100,2),'%') as `机构导航点击pv占比`
,`美购详情页浏览pv`
,(`加购物车点击pv`+`评价列表页点击pv`+`立即支付点击pv`+`私信及电话咨询pv` +`选择美购项目点击pv`
+`机构主页点击pv`+`机构的其他美购点击pv`+`推荐美购点击pv`+`收藏点击pv`
+`右上角购物车点击pv`+`医生主页点击pv`+`分享点击pv`+`机构导航点击pv`) as `美购详情页分发pv加总`
,concat(round((`加购物车点击pv`+`评价列表页点击pv`+`立即支付点击pv`+`私信及电话咨询pv` +`选择美购项目点击pv`
+`机构主页点击pv`+`机构的其他美购点击pv`+`推荐美购点击pv`+`收藏点击pv`
+`右上角购物车点击pv`+`医生主页点击pv`+`分享点击pv`+`机构导航点击pv`)/`美购详情页浏览pv`*100,2),'%') as `美购详情页分发pv占比加总`
,`加购物车点击pv`
,concat(round(`加购物车点击pv`/`美购详情页浏览pv`*100,2),'%') as `加购物车点击pv占比`
,`评价列表页点击pv`
,concat(round(`评价列表页点击pv`/`美购详情页浏览pv`*100,2),'%') as `评价列表页点击pv占比`
,`立即支付点击pv`
,concat(round(`立即支付点击pv`/`美购详情页浏览pv`*100,2),'%') as `立即支付点击pv占比`
,`私信及电话咨询pv`
,concat(round(`私信及电话咨询pv`/`美购详情页浏览pv`*100,2),'%') as `私信及电话咨询pv占比`
,`选择美购项目点击pv`
,concat(round(`选择美购项目点击pv`/`美购详情页浏览pv`*100,2),'%') as `选择美购项目点击pv占比`
,`机构主页点击pv`
,concat(round(`机构主页点击pv`/`美购详情页浏览pv`*100,2),'%') as `机构主页点击pv占比`
,`机构的其他美购点击pv`
,concat(round(`机构的其他美购点击pv`/`美购详情页浏览pv`*100,2),'%') as `机构的其他美购点击pv占比`
,`推荐美购点击pv`
,concat(round(`推荐美购点击pv`/`美购详情页浏览pv`*100,2),'%') as `推荐美购点击pv占比`
,`收藏点击pv`
,concat(round(`收藏点击pv`/`美购详情页浏览pv`*100,2),'%') as `收藏点击pv占比`
,`右上角购物车点击pv`
,concat(round(`右上角购物车点击pv`/`美购详情页浏览pv`*100,2),'%') as `右上角购物车点击pv占比`
,`医生主页点击pv`
,concat(round(`医生主页点击pv`/`美购详情页浏览pv`*100,2),'%') as `医生主页点击pv占比`
,`分享点击pv`
,concat(round(`分享点击pv`/`美购详情页浏览pv`*100,2),'%') as `分享点击pv占比`
,`机构导航点击pv`
,concat(round(`机构导航点击pv`/`美购详情页浏览pv`*100,2),'%') as `机构导航点击pv占比`
FROM
(
SELECT t1.partition_date as `日期`
,t1.device_os_type as `设备类型`
,t1.active_type as `活跃类型`
,t2.channel as `渠道`
,count(case when type='美购详情页' then cl_id end ) as `美购详情页浏览pv`
,count(case when type='加购物车' then cl_id end ) as `加购物车点击pv`
,count(case when type='评价列表页' then cl_id end ) as `评价列表页点击pv`
,count(case when type='立即支付' then cl_id end ) as `立即支付点击pv`
,count(case when type='私信及电话咨询' then cl_id end ) as `私信及电话咨询pv`
,count(case when type='选择美购项目' then cl_id end ) as `选择美购项目点击pv`
,count(case when type='机构主页' then cl_id end ) as `机构主页点击pv`
,count(case when type='机构的其他美购' then cl_id end ) as `机构的其他美购点击pv`
,count(case when type='推荐美购' then cl_id end ) as `推荐美购点击pv`
,count(case when type='收藏' then cl_id end ) as `收藏点击pv`
,count(case when type='右上角购物车' then cl_id end ) as `右上角购物车点击pv`
,count(case when type='医生主页' then cl_id end ) as `医生主页点击pv`
,count(case when type='分享' then cl_id end ) as `分享点击pv`
,count(case when type='机构导航' then cl_id end ) as `机构导航点击pv`
FROM
(
SELECT click.partition_date,click.cl_id,click.type,mas.active_type,mas.device_os_type,mas.channel
FROM
( --浏览需要去掉疑似机构刷量的设备
(
SELECT t1.partition_date as `日期`
,t1.device_type as `设备类型`
,t1.active_type as `活跃类型`
,t2.channel as `渠道`
,count(case when type='美购详情页' then cl_id end ) as `美购详情页浏览pv`
,count(case when type='加购物车' then cl_id end ) as `加购物车点击pv`
,count(case when type='评价列表页' then cl_id end ) as `评价列表页点击pv`
,count(case when type='立即支付' then cl_id end ) as `立即支付点击pv`
,count(case when type='私信及电话咨询' then cl_id end ) as `私信及电话咨询pv`
,count(case when type='选择美购项目' then cl_id end ) as `选择美购项目点击pv`
,count(case when type='机构主页' then cl_id end ) as `机构主页点击pv`
,count(case when type='机构的其他美购' then cl_id end ) as `机构的其他美购点击pv`
,count(case when type='推荐美购' then cl_id end ) as `推荐美购点击pv`
,count(case when type='收藏' then cl_id end ) as `收藏点击pv`
,count(case when type='右上角购物车' then cl_id end ) as `右上角购物车点击pv`
,count(case when type='医生主页' then cl_id end ) as `医生主页点击pv`
,count(case when type='分享' then cl_id end ) as `分享点击pv`
,count(case when type='机构导航' then cl_id end ) as `机构导航点击pv`
FROM
(
SELECT click.partition_date,click.cl_id,click.type,mas.active_type,mas.device_type,mas.channel
FROM
( --浏览需要去掉疑似机构刷量的设备
SELECT pv.partition_date as partition_date,pv.cl_id as cl_id,type
FROM
(
SELECT partition_date,cl_id,'美购详情页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='page_view'
)pv
LEFT JOIN
( -- 去掉疑似机构刷量的PV和UV
SELECT cl_id
FROM online.ml_hospital_spam_pv_day
FROM ml_hospital_spam_pv_day
WHERE partition_date>='20180402' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
UNION ALL
SELECT cl_id
FROM online.ml_hospital_spam_pv_month
FROM ml_hospital_spam_pv_month
WHERE partition_date>='20171101' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
)spam_pv
......@@ -88,8 +89,8 @@ FROM
SELECT partition_date,cl_id, '加购物车' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='welfare_multiattribute_click_add'
......@@ -97,8 +98,8 @@ FROM
SELECT partition_date,cl_id, '右上角购物车' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_navbar_cart'
......@@ -106,7 +107,7 @@ FROM
--点击查看更多评论
SELECT partition_date,cl_id, '评价列表页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_comment'
......@@ -115,7 +116,7 @@ FROM
--点击外显的评价标签
SELECT partition_date,cl_id, '评价列表页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='service_comment_click_tag'
......@@ -124,7 +125,7 @@ FROM
--点击外显的日记卡片
SELECT partition_date,cl_id, '评价列表页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='welfare_detail_comment_click_diary_card'
......@@ -133,7 +134,7 @@ FROM
SELECT partition_date,cl_id, '立即支付' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='welfare_multiattribute_click_buy'
......@@ -142,7 +143,7 @@ FROM
--点击选择更美项目
SELECT partition_date,cl_id, '选择美购项目' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
......@@ -152,7 +153,7 @@ FROM
--7.22新版本--点击外露的美购项目
SELECT partition_date,cl_id, '选择美购项目' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
......@@ -162,7 +163,7 @@ FROM
--7.22新版本--点击查看更多
SELECT partition_date,cl_id, '选择美购项目' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
......@@ -172,7 +173,7 @@ FROM
--点击私信按钮
SELECT partition_date,cl_id, '私信及电话咨询' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_message'
......@@ -181,7 +182,7 @@ FROM
--7.20之后灰度上线的快捷咨询按钮和预约面诊按钮
SELECT partition_date,cl_id, '私信及电话咨询' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
......@@ -191,7 +192,7 @@ FROM
--点击机构下面的在线咨询和电话咨询
SELECT partition_date,cl_id, '私信及电话咨询' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_curearea_contact'
......@@ -201,7 +202,7 @@ FROM
SELECT partition_date,cl_id, '机构主页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_curearea'
......@@ -211,7 +212,7 @@ FROM
SELECT partition_date,cl_id, '机构的其他美购' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_seller_service_item'
......@@ -220,7 +221,7 @@ FROM
SELECT partition_date,cl_id, '机构导航' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_address'
......@@ -229,7 +230,7 @@ FROM
SELECT partition_date,cl_id, '推荐美购' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date <regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_card'
......@@ -240,7 +241,7 @@ FROM
SELECT partition_date,cl_id, '收藏' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_favor'
......@@ -251,7 +252,7 @@ FROM
SELECT partition_date,cl_id, '医生主页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_curearea'
......@@ -261,36 +262,37 @@ FROM
SELECT partition_date,cl_id, '分享' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='page_click_share'
)click
JOIN
(
SELECT
partition_date
,m.device_id, device_os_type
JOIN
(
SELECT partition_date,device_os_type as device_type,m.device_id
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL
or first_channel_source_type in ('promotion_aisi','promotion_koomobi_km00','promotion_koomobi_km01')
or first_channel_source_type like '%longyuzhixing%' or first_channel_source_type like '%jingmeng%'
or first_channel_source_type like '%mailuo%' THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
......@@ -300,12 +302,12 @@ FROM
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
)mas
ON click.cl_id=mas.device_id
AND click.partition_date=mas.partition_date
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_os_type,t1.active_type,t2.channel
)mas
ON click.cl_id=mas.device_id
AND click.partition_date=mas.partition_date
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_type,t1.active_type,t2.channel
)T1
ORDER BY `日期` desc,`设备类型`,`活跃类型`,`渠道`
--美购详情页的分发
SELECT `日期`,`设备类型`,`活跃类型`,`渠道`
,`美购详情页浏览uv`
,`加购物车点击uv`
,concat(round(`加购物车点击uv`/`美购详情页浏览uv`*100,2),'%') as `加购物车点击uv占比`
,`评价列表页点击uv`
,concat(round(`评价列表页点击uv`/`美购详情页浏览uv`*100,2),'%') as `评价列表页点击uv占比`
,`立即支付点击uv`
,concat(round(`立即支付点击uv`/`美购详情页浏览uv`*100,2),'%') as `立即支付点击uv占比`
,`私信及电话咨询uv`
,concat(round(`私信及电话咨询uv`/`美购详情页浏览uv`*100,2),'%') as `私信及电话咨询uv占比`
,`选择美购项目点击uv`
,concat(round(`选择美购项目点击uv`/`美购详情页浏览uv`*100,2),'%') as `选择美购项目点击uv占比`
,`机构主页点击uv`
,concat(round(`机构主页点击uv`/`美购详情页浏览uv`*100,2),'%') as `机构主页点击uv占比`
,`机构的其他美购点击uv`
,concat(round(`机构的其他美购点击uv`/`美购详情页浏览uv`*100,2),'%') as `机构的其他美购点击uv占比`
,`推荐美购点击uv`
,concat(round(`推荐美购点击uv`/`美购详情页浏览uv`*100,2),'%') as `推荐美购点击uv占比`
,`收藏点击uv`
,concat(round(`收藏点击uv`/`美购详情页浏览uv`*100,2),'%') as `收藏点击uv占比`
,`右上角购物车点击uv`
,concat(round(`右上角购物车点击uv`/`美购详情页浏览uv`*100,2),'%') as `右上角购物车点击uv占比`
,`医生主页点击uv`
,concat(round(`医生主页点击uv`/`美购详情页浏览uv`*100,2),'%') as `医生主页点击uv占比`
,`分享点击uv`
,concat(round(`分享点击uv`/`美购详情页浏览uv`*100,2),'%') as `分享点击uv占比`
,`机构导航点击uv`
,concat(round(`机构导航点击uv`/`美购详情页浏览uv`*100,2),'%') as `机构导航点击uv占比`
,`美购详情页浏览uv`
,(`加购物车点击uv`+`评价列表页点击uv`+`立即支付点击uv`+`私信及电话咨询uv` +`选择美购项目点击uv`
+`机构主页点击uv`+`机构的其他美购点击uv`+`推荐美购点击uv`+`收藏点击uv`
+`右上角购物车点击uv`+`医生主页点击uv`+`分享点击uv`+`机构导航点击uv`) as `美购详情页分发uv加总`
,concat(round((`加购物车点击uv`+`评价列表页点击uv`+`立即支付点击uv`+`私信及电话咨询uv` +`选择美购项目点击uv`
+`机构主页点击uv`+`机构的其他美购点击uv`+`推荐美购点击uv`+`收藏点击uv`
+`右上角购物车点击uv`+`医生主页点击uv`+`分享点击uv`+`机构导航点击uv`)/`美购详情页浏览uv`*100,2),'%') as `美购详情页分发uv占比加总`
,`加购物车点击uv`
,concat(round(`加购物车点击uv`/`美购详情页浏览uv`*100,2),'%') as `加购物车点击uv占比`
,`评价列表页点击uv`
,concat(round(`评价列表页点击uv`/`美购详情页浏览uv`*100,2),'%') as `评价列表页点击uv占比`
,`立即支付点击uv`
,concat(round(`立即支付点击uv`/`美购详情页浏览uv`*100,2),'%') as `立即支付点击uv占比`
,`私信及电话咨询uv`
,concat(round(`私信及电话咨询uv`/`美购详情页浏览uv`*100,2),'%') as `私信及电话咨询uv占比`
,`选择美购项目点击uv`
,concat(round(`选择美购项目点击uv`/`美购详情页浏览uv`*100,2),'%') as `选择美购项目点击uv占比`
,`机构主页点击uv`
,concat(round(`机构主页点击uv`/`美购详情页浏览uv`*100,2),'%') as `机构主页点击uv占比`
,`机构的其他美购点击uv`
,concat(round(`机构的其他美购点击uv`/`美购详情页浏览uv`*100,2),'%') as `机构的其他美购点击uv占比`
,`推荐美购点击uv`
,concat(round(`推荐美购点击uv`/`美购详情页浏览uv`*100,2),'%') as `推荐美购点击uv占比`
,`收藏点击uv`
,concat(round(`收藏点击uv`/`美购详情页浏览uv`*100,2),'%') as `收藏点击uv占比`
,`右上角购物车点击uv`
,concat(round(`右上角购物车点击uv`/`美购详情页浏览uv`*100,2),'%') as `右上角购物车点击uv占比`
,`医生主页点击uv`
,concat(round(`医生主页点击uv`/`美购详情页浏览uv`*100,2),'%') as `医生主页点击uv占比`
,`分享点击uv`
,concat(round(`分享点击uv`/`美购详情页浏览uv`*100,2),'%') as `分享点击uv占比`
,`机构导航点击uv`
,concat(round(`机构导航点击uv`/`美购详情页浏览uv`*100,2),'%') as `机构导航点击uv占比`
FROM
(
SELECT t1.partition_date as `日期`
,t1.device_os_type as `设备类型`
,t1.active_type as `活跃类型`
,t2.channel as `渠道`
,count(distinct case when type='美购详情页' then cl_id end ) as `美购详情页浏览uv`
,count(distinct case when type='加购物车' then cl_id end ) as `加购物车点击uv`
,count(distinct case when type='评价列表页' then cl_id end ) as `评价列表页点击uv`
,count(distinct case when type='立即支付' then cl_id end ) as `立即支付点击uv`
,count(distinct case when type='私信及电话咨询' then cl_id end ) as `私信及电话咨询uv`
,count(distinct case when type='选择美购项目' then cl_id end ) as `选择美购项目点击uv`
,count(distinct case when type='机构主页' then cl_id end ) as `机构主页点击uv`
,count(distinct case when type='机构的其他美购' then cl_id end ) as `机构的其他美购点击uv`
,count(distinct case when type='推荐美购' then cl_id end ) as `推荐美购点击uv`
,count(distinct case when type='收藏' then cl_id end ) as `收藏点击uv`
,count(distinct case when type='右上角购物车' then cl_id end ) as `右上角购物车点击uv`
,count(distinct case when type='医生主页' then cl_id end ) as `医生主页点击uv`
,count(distinct case when type='分享' then cl_id end ) as `分享点击uv`
,count(distinct case when type='机构导航' then cl_id end ) as `机构导航点击uv`
FROM
(
SELECT click.partition_date,click.cl_id,click.type,mas.active_type,mas.device_os_type,mas.channel
FROM
( --浏览需要去掉疑似机构刷量的设备
SELECT pv.partition_date as partition_date,pv.cl_id as cl_id,type
(
SELECT t1.partition_date as `日期`
,t1.device_type as `设备类型`
,t1.active_type as `活跃类型`
,t2.channel as `渠道`
,count(case when type='美购详情页' then cl_id end ) as `美购详情页浏览uv`
,count(case when type='加购物车' then cl_id end ) as `加购物车点击uv`
,count(case when type='评价列表页' then cl_id end ) as `评价列表页点击uv`
,count(case when type='立即支付' then cl_id end ) as `立即支付点击uv`
,count(case when type='私信及电话咨询' then cl_id end ) as `私信及电话咨询uv`
,count(case when type='选择美购项目' then cl_id end ) as `选择美购项目点击uv`
,count(case when type='机构主页' then cl_id end ) as `机构主页点击uv`
,count(case when type='机构的其他美购' then cl_id end ) as `机构的其他美购点击uv`
,count(case when type='推荐美购' then cl_id end ) as `推荐美购点击uv`
,count(case when type='收藏' then cl_id end ) as `收藏点击uv`
,count(case when type='右上角购物车' then cl_id end ) as `右上角购物车点击uv`
,count(case when type='医生主页' then cl_id end ) as `医生主页点击uv`
,count(case when type='分享' then cl_id end ) as `分享点击uv`
,count(case when type='机构导航' then cl_id end ) as `机构导航点击uv`
FROM
(
SELECT click.partition_date,click.cl_id,click.type,mas.active_type,mas.device_type,mas.channel
FROM
( --浏览需要去掉疑似机构刷量的设备
SELECT uv.partition_date as partition_date,uv.cl_id as cl_id,type
FROM
(
SELECT partition_date,cl_id,'美购详情页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='page_view'
)pv
)uv
LEFT JOIN
(
( -- 去掉疑似机构刷量的UV和UV
SELECT cl_id
FROM online.ml_hospital_spam_pv_day
FROM ml_hospital_spam_pv_day
WHERE partition_date>='20180402' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
UNION ALL
SELECT cl_id
FROM online.ml_hospital_spam_pv_month
FROM ml_hospital_spam_pv_month
WHERE partition_date>='20171101' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
)spam_pv
on pv.cl_id=spam_pv.cl_id
on uv.cl_id=spam_pv.cl_id
WHERE spam_pv.cl_id IS NULL
UNION ALL
SELECT partition_date,cl_id, '加购物车' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='welfare_multiattribute_click_add'
UNION ALL
SELECT partition_date,cl_id, '右上角购物车' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_navbar_cart'
UNION ALL
--点击查看更多评论
SELECT partition_date,cl_id, '评价列表页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_comment'
UNION ALL
--点击外显的评价标签
SELECT partition_date,cl_id, '评价列表页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='service_comment_click_tag'
UNION ALL
--点击外显的日记卡片
SELECT partition_date,cl_id, '评价列表页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='welfare_detail_comment_click_diary_card'
UNION ALL
SELECT partition_date,cl_id, '立即支付' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='welfare_multiattribute_click_buy'
UNION ALL
--点击选择更美项目
SELECT partition_date,cl_id, '选择美购项目' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
AND params['button_name']='sku_choose'
UNION ALL
--7.22新版本--点击外露的美购项目
SELECT partition_date,cl_id, '选择美购项目' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
AND params['button_name']='service_sku'
UNION ALL
--7.22新版本--点击查看更多
SELECT partition_date,cl_id, '选择美购项目' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
AND params['button_name']='sku_all'
UNION ALL
--点击私信按钮
SELECT partition_date,cl_id, '私信及电话咨询' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_message'
UNION ALL
--7.20之后灰度上线的快捷咨询按钮和预约面诊按钮
SELECT partition_date,cl_id, '私信及电话咨询' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
AND params['button_name'] in ('question_tag','appointment')
UNION ALL
--点击机构下面的在线咨询和电话咨询
SELECT partition_date,cl_id, '私信及电话咨询' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_curearea_contact'
AND params['connect_type'] in ('onlineconsult','phone')
UNION ALL
SELECT partition_date,cl_id, '机构主页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_curearea'
AND params['cure_type']='organization'
UNION ALL
SELECT partition_date,cl_id, '机构的其他美购' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_seller_service_item'
UNION ALL
SELECT partition_date,cl_id, '机构导航' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_address'
UNION ALL
SELECT partition_date,cl_id, '推荐美购' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date <regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_card'
AND params['card_content_type']='service'
AND params['tab_name']='推荐'
UNION ALL
SELECT partition_date,cl_id, '收藏' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_favor'
AND params['favor_type']='service'
AND params['motion']='do'
UNION ALL
SELECT partition_date,cl_id, '医生主页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_curearea'
AND params['cure_type']='doctor'
UNION ALL
SELECT partition_date,cl_id, '分享' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='page_click_share'
SELECT partition_date,cl_id, '加购物车' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='welfare_multiattribute_click_add'
UNION ALL
SELECT partition_date,cl_id, '右上角购物车' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_navbar_cart'
UNION ALL
--点击查看更多评论
SELECT partition_date,cl_id, '评价列表页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_comment'
UNION ALL
--点击外显的评价标签
SELECT partition_date,cl_id, '评价列表页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='service_comment_click_tag'
UNION ALL
--点击外显的日记卡片
SELECT partition_date,cl_id, '评价列表页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='welfare_detail_comment_click_diary_card'
UNION ALL
SELECT partition_date,cl_id, '立即支付' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='welfare_multiattribute_click_buy'
UNION ALL
--点击选择更美项目
SELECT partition_date,cl_id, '选择美购项目' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
AND params['button_name']='sku_choose'
UNION ALL
--7.22新版本--点击外露的美购项目
SELECT partition_date,cl_id, '选择美购项目' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
AND params['button_name']='service_sku'
UNION ALL
--7.22新版本--点击查看更多
SELECT partition_date,cl_id, '选择美购项目' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
AND params['button_name']='sku_all'
UNION ALL
--点击私信按钮
SELECT partition_date,cl_id, '私信及电话咨询' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_message'
UNION ALL
--7.20之后灰度上线的快捷咨询按钮和预约面诊按钮
SELECT partition_date,cl_id, '私信及电话咨询' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
AND params['button_name'] in ('question_tag','appointment')
UNION ALL
--点击机构下面的在线咨询和电话咨询
SELECT partition_date,cl_id, '私信及电话咨询' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_curearea_contact'
AND params['connect_type'] in ('onlineconsult','phone')
UNION ALL
SELECT partition_date,cl_id, '机构主页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_curearea'
AND params['cure_type']='organization'
UNION ALL
SELECT partition_date,cl_id, '机构的其他美购' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_seller_service_item'
UNION ALL
SELECT partition_date,cl_id, '机构导航' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_address'
UNION ALL
SELECT partition_date,cl_id, '推荐美购' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date <regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_card'
AND params['card_content_type']='service'
AND params['tab_name']='推荐'
UNION ALL
SELECT partition_date,cl_id, '收藏' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_favor'
AND params['favor_type']='service'
AND params['motion']='do'
UNION ALL
SELECT partition_date,cl_id, '医生主页' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_curearea'
AND params['cure_type']='doctor'
UNION ALL
SELECT partition_date,cl_id, '分享' as type
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='page_click_share'
)click
JOIN
(
SELECT
partition_date
,m.device_id, device_os_type
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
)mas
ON click.cl_id=mas.device_id
AND click.partition_date=mas.partition_date
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_os_type,t1.active_type,t2.channel
)T1
ORDER BY `日期` desc,`设备类型`,`活跃类型`,`渠道`
\ No newline at end of file
JOIN
(
SELECT partition_date,device_os_type as device_type,m.device_id
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL
or first_channel_source_type in ('promotion_aisi','promotion_koomobi_km00','promotion_koomobi_km01')
or first_channel_source_type like '%longyuzhixing%' or first_channel_source_type like '%jingmeng%'
or first_channel_source_type like '%mailuo%' THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
)mas
ON click.cl_id=mas.device_id
AND click.partition_date=mas.partition_date
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_type,t1.active_type,t2.channel
)T1
ORDER BY `日期` desc,`设备类型`,`活跃类型`,`渠道`
--美购详情页的来源
SELECT T1.partition_date as `日期`
,T1.device_os_type as `设备类型`
,T1.active_type as `活跃类型`
,T1.channel as `渠道`
,T1.wel_pv as `美购详情页pv`
,(T2.search_result_welfare_pv+T2.welfare_list_pv+T2.organization_detail_pv+T2.category_pv+T2.sign_pv
+T2.special_pv+T2.my_cart_pv+T2.search_result_more_pv+T2.welfare_home_pv+T2.conversation_detail_pv
+T2.wel_pv+T2.order_detail_pv+T2.expert_detail_pv+T2.ai_report_pv+T2.diary_detail_pv+T2.zone_pv) as `转化美购pv总量`
,concat(round((T2.search_result_welfare_pv+T2.welfare_list_pv+T2.organization_detail_pv+T2.category_pv+T2.sign_pv
+T2.special_pv+T2.my_cart_pv+T2.search_result_more_pv+T2.welfare_home_pv+T2.conversation_detail_pv
+T2.wel_pv+T2.order_detail_pv+T2.expert_detail_pv+T2.ai_report_pv+T2.diary_detail_pv+T2.zone_pv)/T1.wel_pv*100,2),'%') as `转化美购pv占比加总`
,T1.search_result_welfare_pv as `搜索结果美购页pv`
,T2.search_result_welfare_pv as `搜索结果美购页-转化pv`
,T3.result_wel_add_pv as `搜索结果美购页-转化点击加车pv`
,T3.result_wel_buy_pv as `搜索结果美购页-转化点击立即支付pv`
,T3.result_wel_msg_pv as `搜索结果美购页-转化点击私信咨询pv`
,concat(round(T2.search_result_welfare_pv/T1.search_result_welfare_pv*100,2),'%') as `搜索结果美购页-转化pv率`
,concat(round(T2.search_result_welfare_pv/T1.wel_pv*100,2),'%') as `搜索结果美购页-转化美购pv占比`
,concat(round(T3.result_wel_add_pv/T2.search_result_welfare_pv*100,2),'%') as `搜索结果美购页-点击加车率`
,concat(round(T3.result_wel_buy_pv/T2.search_result_welfare_pv*100,2),'%') as `搜索结果美购页-点击立即支付率`
,concat(round(T3.result_wel_msg_pv/T2.search_result_welfare_pv*100,2),'%') as `搜索结果美购页-点击私信咨询率`
,T1.welfare_list_pv as `美购列表页pv`
,T2.welfare_list_pv as `美购列表页-转化pv`
,T3.wel_list_add_pv as `美购列表页-转化点击加车pv`
,T3.wel_list_buy_pv as `美购列表页-转化点击立即支付pv`
,T3.wel_list_msg_pv as `美购列表页-转化点击私信咨询pv`
,concat(round(T2.welfare_list_pv/T1.welfare_list_pv*100,2),'%') as `美购列表页-转化pv率`
,concat(round(T2.welfare_list_pv/T1.wel_pv*100,2),'%') as `美购列表页-转化美购pv占比`
,concat(round(T3.wel_list_add_pv/T2.welfare_list_pv*100,2),'%') as `美购列表页-点击加车率`
,concat(round(T3.wel_list_buy_pv/T2.welfare_list_pv*100,2),'%') as `美购列表页-点击立即支付率`
,concat(round(T3.wel_list_msg_pv/T2.welfare_list_pv*100,2),'%') as `美购列表页-点击私信咨询率`
,T1.organization_detail_pv as `医院主页pv`
,T2.organization_detail_pv as `医院主页-转化pv`
,T3.org_add_pv as `医院主页-转化点击加车pv`
,T3.org_buy_pv as `医院主页-转化点击立即支付pv`
,T3.org_msg_pv as `医院主页-转化点击私信咨询pv`
,concat(round(T2.organization_detail_pv/T1.organization_detail_pv*100,2),'%') as `医院主页-转化pv率`
,concat(round(T2.organization_detail_pv/T1.wel_pv*100,2),'%') as `医院主页-转化美购pv占比`
,concat(round(T3.org_add_pv/T2.organization_detail_pv*100,2),'%') as `医院主页-点击加车率`
,concat(round(T3.org_buy_pv/T2.organization_detail_pv*100,2),'%') as `医院主页-点击立即支付率`
,concat(round(T3.org_msg_pv/T2.organization_detail_pv*100,2),'%') as `医院主页-点击私信咨询率`
,T1.category_pv as `品类聚合页pv`
,T2.category_pv as `品类聚合页-转化pv`
,T3.category_add_pv as `品类聚合页-转化点击加车pv`
,T3.category_buy_pv as `品类聚合页-转化点击立即支付pv`
,T3.category_msg_pv as `品类聚合页-转化点击私信咨询pv`
,concat(round(T2.category_pv/T1.category_pv*100,2),'%') as `品类聚合页-转化pv率`
,concat(round(T2.category_pv/T1.wel_pv*100,2),'%') as `品类聚合页-转化美购pv占比`
,concat(round(T3.category_add_pv/T2.category_pv*100,2),'%') as `品类聚合页-点击加车率`
,concat(round(T3.category_buy_pv/T2.category_pv*100,2),'%') as `品类聚合页-点击立即支付率`
,concat(round(T3.category_msg_pv/T2.category_pv*100,2),'%') as `品类聚合页-点击私信咨询率`
,T1.sign_pv as `签到页pv`
,T2.sign_pv as `签到页-转化pv`
,T3.sign_add_pv as `签到页-转化点击加车pv`
,T3.sign_buy_pv as `签到页-转化点击立即支付pv`
,T3.sign_msg_pv as `签到页-转化点击私信咨询pv`
,concat(round(T2.sign_pv/T1.sign_pv*100,2),'%') as `签到页-转化pv率`
,concat(round(T2.sign_pv/T1.wel_pv*100,2),'%') as `签到页-转化美购pv占比`
,concat(round(T3.sign_add_pv/T2.sign_pv*100,2),'%') as `签到页-点击加车率`
,concat(round(T3.sign_buy_pv/T2.sign_pv*100,2),'%') as `签到页-点击立即支付率`
,concat(round(T3.sign_msg_pv/T2.sign_pv*100,2),'%') as `签到页-点击私信咨询率`
,T1.special_pv as `专题和大促页pv`
,T2.special_pv as `专题和大促页-转化pv`
,T3.special_add_pv as `专题和大促页-转化点击加车pv`
,T3.special_buy_pv as `专题和大促页-转化点击立即支付pv`
,T3.special_msg_pv as `专题和大促页-转化点击私信咨询pv`
,concat(round(T2.special_pv/T1.special_pv*100,2),'%') as `专题和大促页-转化pv率`
,concat(round(T2.special_pv/T1.wel_pv*100,2),'%') as `专题和大促页-转化美购pv占比`
,concat(round(T3.special_add_pv/T2.special_pv*100,2),'%') as `专题和大促页-点击加车率`
,concat(round(T3.special_buy_pv/T2.special_pv*100,2),'%') as `专题和大促页-点击立即支付率`
,concat(round(T3.special_msg_pv/T2.special_pv*100,2),'%') as `专题和大促页-点击私信咨询率`
,T1.my_cart_pv as`购物车pv`
,T2.my_cart_pv as`购物车-转化pv`
,T3.cart_add_pv as `购物车-转化点击加车pv`
,T3.cart_buy_pv as `购物车-转化点击立即支付pv`
,T3.cart_msg_pv as `购物车-转化点击私信咨询pv`
,concat(round(T2.my_cart_pv/T1.my_cart_pv*100,2),'%') as `购物车-转化pv率`
,concat(round(T2.my_cart_pv/T1.wel_pv*100,2),'%') as `购物车-转化美购pv占比`
,concat(round(T3.cart_add_pv/T2.my_cart_pv*100,2),'%') as `购物车-点击加车率`
,concat(round(T3.cart_buy_pv/T2.my_cart_pv*100,2),'%') as `购物车-点击立即支付率`
,concat(round(T3.cart_msg_pv/T2.my_cart_pv*100,2),'%') as `购物车-点击私信咨询率`
,T1.search_result_more_pv as `搜索结果综合页pv`
,T2.search_result_more_pv as `搜索结果综合页-转化pv`
,T3.result_more_add_pv as `搜索结果综合页-转化点击加车pv`
,T3.result_more_buy_pv as `搜索结果综合页-转化点击立即支付pv`
,T3.result_more_msg_pv as `搜索结果综合页-转化点击私信咨询pv`
,concat(round(T2.search_result_more_pv/T1.search_result_more_pv*100,2),'%') as `搜索结果综合页-转化pv率`
,concat(round(T2.search_result_more_pv/T1.wel_pv*100,2),'%') as `搜索结果综合页-转化美购pv占比`
,concat(round(T3.result_more_add_pv/T2.search_result_more_pv*100,2),'%') as `搜索结果综合页-点击加车率`
,concat(round(T3.result_more_buy_pv/T2.search_result_more_pv*100,2),'%') as `搜索结果综合页-点击立即支付率`
,concat(round(T3.result_more_msg_pv/T2.search_result_more_pv*100,2),'%') as `搜索结果综合页-点击私信咨询率`
,T1.welfare_home_pv as `美购首页pv`
,T2.welfare_home_pv as `美购首页-转化pv`
,T3.wel_home_add_pv as `美购首页-转化点击加车pv`
,T3.wel_home_buy_pv as `美购首页-转化点击立即支付pv`
,T3.wel_home_msg_pv as `美购首页-转化点击私信咨询pv`
,concat(round(T2.welfare_home_pv/T1.welfare_home_pv*100,2),'%') as `美购首页-转化pv率`
,concat(round(T2.welfare_home_pv/T1.wel_pv*100,2),'%') as `美购首页-转化美购pv占比`
,concat(round(T3.wel_home_add_pv/T2.welfare_home_pv*100,2),'%') as `美购首页-点击加车率`
,concat(round(T3.wel_home_buy_pv/T2.welfare_home_pv*100,2),'%') as `美购首页-点击立即支付率`
,concat(round(T3.wel_home_msg_pv/T2.welfare_home_pv*100,2),'%') as `美购首页-点击私信咨询率`
,T1.conversation_detail_pv as `私信详情页pv`
,T2.conversation_detail_pv as `私信详情页-转化pv`
,T3.conv_add_pv as `私信详情页-转化点击加车pv`
,T3.conv_buy_pv as `私信详情页-转化点击立即支付pv`
,T3.conv_msg_pv as `私信详情页-转化点击私信咨询pv`
,concat(round(T2.conversation_detail_pv/T1.conversation_detail_pv*100,2),'%') as `私信详情页-转化pv率`
,concat(round(T2.conversation_detail_pv/T1.wel_pv*100,2),'%') as `私信详情页-转化美购pv占比`
,concat(round(T3.conv_add_pv/T2.conversation_detail_pv*100,2),'%') as `私信详情页-点击加车率`
,concat(round(T3.conv_buy_pv/T2.conversation_detail_pv*100,2),'%') as `私信详情页-点击立即支付率`
,concat(round(T3.conv_msg_pv/T2.conversation_detail_pv*100,2),'%') as `私信详情页-点击私信咨询率`
,T1.wel_pv as `美购详情页pv`
,T2.wel_pv as `其他美购详情页-转化pv`
,T3.wel_add_pv as `其他美购详情页-转化点击加车pv`
,T3.wel_buy_pv as `其他美购详情页-转化点击立即支付pv`
,T3.wel_msg_pv as `其他美购详情页-转化点击私信咨询pv`
,concat(round(T2.wel_pv/T1.wel_pv*100,2),'%') as `其他美购详情页-转化pv率`
,concat(round(T2.wel_pv/T1.wel_pv*100,2),'%') as `其他美购详情页-转化美购pv占比`
,concat(round(T3.wel_add_pv/T2.wel_pv*100,2),'%') as `其他美购详情页-点击加车率`
,concat(round(T3.wel_buy_pv/T2.wel_pv*100,2),'%') as `其他美购详情页-点击立即支付率`
,concat(round(T3.wel_msg_pv/T2.wel_pv*100,2),'%') as `其他美购详情页-点击私信咨询率`
,T1.order_detail_pv as `订单详情页pv`
,T2.order_detail_pv as `订单详情页-转化pv`
,T3.order_add_pv as `订单详情页-转化点击加车pv`
,T3.order_buy_pv as `订单详情页-转化点击立即支付pv`
,T3.order_msg_pv as `订单详情页-转化点击私信咨询pv`
,concat(round(T2.order_detail_pv/T1.order_detail_pv*100,2),'%') as `订单详情页-转化pv率`
,concat(round(T2.order_detail_pv/T1.wel_pv*100,2),'%') as `订单详情页-转化美购pv占比`
,concat(round(T3.order_add_pv/T2.order_detail_pv*100,2),'%') as `订单详情页-点击加车率`
,concat(round(T3.order_buy_pv/T2.order_detail_pv*100,2),'%') as `订单详情页-点击立即支付率`
,concat(round(T3.order_msg_pv/T2.order_detail_pv*100,2),'%') as `订单详情页-点击私信咨询率`
,T1.expert_detail_pv as `医生主页pv`
,T2.expert_detail_pv as `医生主页-转化pv`
,T3.exp_add_pv as `医生主页-转化点击加车pv`
,T3.exp_buy_pv as `医生主页-转化点击立即支付pv`
,T3.exp_msg_pv as `医生主页-转化点击私信咨询pv`
,concat(round(T2.expert_detail_pv/T1.expert_detail_pv*100,2),'%') as `医生主页-转化pv率`
,concat(round(T2.expert_detail_pv/T1.wel_pv*100,2),'%') as `医生主页-转化美购pv占比`
,concat(round(T3.exp_add_pv/T2.expert_detail_pv*100,2),'%') as `医生主页-点击加车率`
,concat(round(T3.exp_buy_pv/T2.expert_detail_pv*100,2),'%') as `医生主页-点击立即支付率`
,concat(round(T3.exp_msg_pv/T2.expert_detail_pv*100,2),'%') as `医生主页-点击私信咨询率`
,T1.ai_report_pv as `AI结果页pv`
,T2.ai_report_pv as `AI结果页-转化pv`
,T3.ai_add_pv as `AI结果页-转化点击加车pv`
,T3.ai_buy_pv as `AI结果页-转化点击立即支付pv`
,T3.ai_msg_pv as `AI结果页-转化点击私信咨询pv`
,concat(round(T2.ai_report_pv/T1.ai_report_pv*100,2),'%') as `AI结果页-转化pv率`
,concat(round(T2.ai_report_pv/T1.wel_pv*100,2),'%') as `AI结果页-转化美购pv占比`
,concat(round(T3.ai_add_pv/T2.ai_report_pv*100,2),'%') as `AI结果页-点击加车率`
,concat(round(T3.ai_buy_pv/T2.ai_report_pv*100,2),'%') as `AI结果页-点击立即支付率`
,concat(round(T3.ai_msg_pv/T2.ai_report_pv*100,2),'%') as `AI结果页-点击私信咨询率`
,T1.diary_detail_pv as `日记本详情页pv`
,T2.diary_detail_pv as `日记本详情页-转化pv`
,T3.diary_add_pv as `日记本详情页-转化点击加车pv`
,T3.diary_buy_pv as `日记本详情页-转化点击立即支付pv`
,T3.diary_msg_pv as `日记本详情页-转化点击私信咨询pv`
,concat(round(T2.diary_detail_pv/T1.diary_detail_pv*100,2),'%') as `日记本详情页-转化pv率`
,concat(round(T2.diary_detail_pv/T1.wel_pv*100,2),'%') as `日记本详情页-转化美购pv占比`
,concat(round(T3.diary_add_pv/T2.diary_detail_pv*100,2),'%') as `日记本详情页-点击加车率`
,concat(round(T3.diary_buy_pv/T2.diary_detail_pv*100,2),'%') as `日记本详情页-点击立即支付率`
,concat(round(T3.diary_msg_pv/T2.diary_detail_pv*100,2),'%') as `日记本详情页-点击私信咨询率`
,T1.zone_pv as `内容聚合页pv`
,T2.zone_pv as `内容聚合页-转化pv`
,T3.zone_add_pv as `内容聚合页-转化点击加车pv`
,T3.zone_buy_pv as `内容聚合页-转化点击立即支付pv`
,T3.zone_msg_pv as `内容聚合页-转化点击私信咨询pv`
,concat(round(T2.zone_pv/T1.zone_pv*100,2),'%') as `内容聚合页-转化pv率`
,concat(round(T2.zone_pv/T1.wel_pv*100,2),'%') as `内容聚合页-转化美购pv占比`
,concat(round(T3.zone_add_pv/T2.zone_pv*100,2),'%') as `内容聚合页-点击加车率`
,concat(round(T3.zone_buy_pv/T2.zone_pv*100,2),'%') as `内容聚合页-点击立即支付率`
,concat(round(T3.zone_msg_pv/T2.zone_pv*100,2),'%') as `内容聚合页-点击私信咨询率`
,T1.device_type as `设备类型`
,T1.active_type as `活跃类型`
,T1.channel as `渠道`
,T1.wel_pv as `美购详情页pv`
,(T2.search_result_welfare_pv+T2.welfare_list_pv+T2.organization_detail_pv+T2.category_pv+T2.sign_pv
+T2.special_pv+T2.my_cart_pv+T2.search_result_more_pv+T2.welfare_home_pv+T2.conversation_detail_pv
+T2.wel_pv+T2.order_detail_pv+T2.expert_detail_pv+T2.ai_report_pv+T2.diary_detail_pv+T2.zone_pv) as `转化美购pv总量`
,concat(round((T2.search_result_welfare_pv+T2.welfare_list_pv+T2.organization_detail_pv+T2.category_pv+T2.sign_pv
+T2.special_pv+T2.my_cart_pv+T2.search_result_more_pv+T2.welfare_home_pv+T2.conversation_detail_pv
+T2.wel_pv+T2.order_detail_pv+T2.expert_detail_pv+T2.ai_report_pv+T2.diary_detail_pv+T2.zone_pv)/T1.wel_pv*100,2),'%') as `转化美购pv占比加总`
,T1.search_result_welfare_pv as `搜索结果美购页pv`
,T2.search_result_welfare_pv as `搜索结果美购页-转化pv`
,T3.result_wel_add_pv as `搜索结果美购页-转化点击加车pv`
,T3.result_wel_buy_pv as `搜索结果美购页-转化点击立即支付pv`
,T3.result_wel_msg_pv as `搜索结果美购页-转化点击私信咨询pv`
,concat(round(T2.search_result_welfare_pv/T1.search_result_welfare_pv*100,2),'%') as `搜索结果美购页-转化pv率`
,concat(round(T2.search_result_welfare_pv/T1.wel_pv*100,2),'%') as `搜索结果美购页-转化美购pv占比`
,concat(round(T3.result_wel_add_pv/T2.search_result_welfare_pv*100,2),'%') as `搜索结果美购页-点击加车率`
,concat(round(T3.result_wel_buy_pv/T2.search_result_welfare_pv*100,2),'%') as `搜索结果美购页-点击立即支付率`
,concat(round(T3.result_wel_msg_pv/T2.search_result_welfare_pv*100,2),'%') as `搜索结果美购页-点击私信咨询率`
,T1.organization_detail_pv as `医院主页pv`
,T2.organization_detail_pv as `医院主页-转化pv`
,T3.org_add_pv as `医院主页-转化点击加车pv`
,T3.org_buy_pv as `医院主页-转化点击立即支付pv`
,T3.org_msg_pv as `医院主页-转化点击私信咨询pv`
,concat(round(T2.organization_detail_pv/T1.organization_detail_pv*100,2),'%') as `医院主页-转化pv率`
,concat(round(T2.organization_detail_pv/T1.wel_pv*100,2),'%') as `医院主页-转化美购pv占比`
,concat(round(T3.org_add_pv/T2.organization_detail_pv*100,2),'%') as `医院主页-点击加车率`
,concat(round(T3.org_buy_pv/T2.organization_detail_pv*100,2),'%') as `医院主页-点击立即支付率`
,concat(round(T3.org_msg_pv/T2.organization_detail_pv*100,2),'%') as `医院主页-点击私信咨询率`
,T1.category_pv as `品类聚合页pv`
,T2.category_pv as `品类聚合页-转化pv`
,T3.category_add_pv as `品类聚合页-转化点击加车pv`
,T3.category_buy_pv as `品类聚合页-转化点击立即支付pv`
,T3.category_msg_pv as `品类聚合页-转化点击私信咨询pv`
,concat(round(T2.category_pv/T1.category_pv*100,2),'%') as `品类聚合页-转化pv率`
,concat(round(T2.category_pv/T1.wel_pv*100,2),'%') as `品类聚合页-转化美购pv占比`
,concat(round(T3.category_add_pv/T2.category_pv*100,2),'%') as `品类聚合页-点击加车率`
,concat(round(T3.category_buy_pv/T2.category_pv*100,2),'%') as `品类聚合页-点击立即支付率`
,concat(round(T3.category_msg_pv/T2.category_pv*100,2),'%') as `品类聚合页-点击私信咨询率`
,T1.conversation_detail_pv as `私信详情页pv`
,T2.conversation_detail_pv as `私信详情页-转化pv`
,T3.conv_add_pv as `私信详情页-转化点击加车pv`
,T3.conv_buy_pv as `私信详情页-转化点击立即支付pv`
,T3.conv_msg_pv as `私信详情页-转化点击私信咨询pv`
,concat(round(T2.conversation_detail_pv/T1.conversation_detail_pv*100,2),'%') as `私信详情页-转化pv率`
,concat(round(T2.conversation_detail_pv/T1.wel_pv*100,2),'%') as `私信详情页-转化美购pv占比`
,concat(round(T3.conv_add_pv/T2.conversation_detail_pv*100,2),'%') as `私信详情页-点击加车率`
,concat(round(T3.conv_buy_pv/T2.conversation_detail_pv*100,2),'%') as `私信详情页-点击立即支付率`
,concat(round(T3.conv_msg_pv/T2.conversation_detail_pv*100,2),'%') as `私信详情页-点击私信咨询率`
,T1.welfare_list_pv as `美购列表页pv`
,T2.welfare_list_pv as `美购列表页-转化pv`
,T3.wel_list_add_pv as `美购列表页-转化点击加车pv`
,T3.wel_list_buy_pv as `美购列表页-转化点击立即支付pv`
,T3.wel_list_msg_pv as `美购列表页-转化点击私信咨询pv`
,concat(round(T2.welfare_list_pv/T1.welfare_list_pv*100,2),'%') as `美购列表页-转化pv率`
,concat(round(T2.welfare_list_pv/T1.wel_pv*100,2),'%') as `美购列表页-转化美购pv占比`
,concat(round(T3.wel_list_add_pv/T2.welfare_list_pv*100,2),'%') as `美购列表页-点击加车率`
,concat(round(T3.wel_list_buy_pv/T2.welfare_list_pv*100,2),'%') as `美购列表页-点击立即支付率`
,concat(round(T3.wel_list_msg_pv/T2.welfare_list_pv*100,2),'%') as `美购列表页-点击私信咨询率`
,T1.my_cart_pv as`购物车pv`
,T2.my_cart_pv as`购物车-转化pv`
,T3.cart_add_pv as `购物车-转化点击加车pv`
,T3.cart_buy_pv as `购物车-转化点击立即支付pv`
,T3.cart_msg_pv as `购物车-转化点击私信咨询pv`
,concat(round(T2.my_cart_pv/T1.my_cart_pv*100,2),'%') as `购物车-转化pv率`
,concat(round(T2.my_cart_pv/T1.wel_pv*100,2),'%') as `购物车-转化美购pv占比`
,concat(round(T3.cart_add_pv/T2.my_cart_pv*100,2),'%') as `购物车-点击加车率`
,concat(round(T3.cart_buy_pv/T2.my_cart_pv*100,2),'%') as `购物车-点击立即支付率`
,concat(round(T3.cart_msg_pv/T2.my_cart_pv*100,2),'%') as `购物车-点击私信咨询率`
,T1.search_result_more_pv as `搜索结果综合页pv`
,T2.search_result_more_pv as `搜索结果综合页-转化pv`
,T3.result_more_add_pv as `搜索结果综合页-转化点击加车pv`
,T3.result_more_buy_pv as `搜索结果综合页-转化点击立即支付pv`
,T3.result_more_msg_pv as `搜索结果综合页-转化点击私信咨询pv`
,concat(round(T2.search_result_more_pv/T1.search_result_more_pv*100,2),'%') as `搜索结果综合页-转化pv率`
,concat(round(T2.search_result_more_pv/T1.wel_pv*100,2),'%') as `搜索结果综合页-转化美购pv占比`
,concat(round(T3.result_more_add_pv/T2.search_result_more_pv*100,2),'%') as `搜索结果综合页-点击加车率`
,concat(round(T3.result_more_buy_pv/T2.search_result_more_pv*100,2),'%') as `搜索结果综合页-点击立即支付率`
,concat(round(T3.result_more_msg_pv/T2.search_result_more_pv*100,2),'%') as `搜索结果综合页-点击私信咨询率`
,T1.order_detail_pv as `订单详情页pv`
,T2.order_detail_pv as `订单详情页-转化pv`
,T3.order_add_pv as `订单详情页-转化点击加车pv`
,T3.order_buy_pv as `订单详情页-转化点击立即支付pv`
,T3.order_msg_pv as `订单详情页-转化点击私信咨询pv`
,concat(round(T2.order_detail_pv/T1.order_detail_pv*100,2),'%') as `订单详情页-转化pv率`
,concat(round(T2.order_detail_pv/T1.wel_pv*100,2),'%') as `订单详情页-转化美购pv占比`
,concat(round(T3.order_add_pv/T2.order_detail_pv*100,2),'%') as `订单详情页-点击加车率`
,concat(round(T3.order_buy_pv/T2.order_detail_pv*100,2),'%') as `订单详情页-点击立即支付率`
,concat(round(T3.order_msg_pv/T2.order_detail_pv*100,2),'%') as `订单详情页-点击私信咨询率`
,T1.special_pv as `专题和大促页pv`
,T2.special_pv as `专题和大促页-转化pv`
,T3.special_add_pv as `专题和大促页-转化点击加车pv`
,T3.special_buy_pv as `专题和大促页-转化点击立即支付pv`
,T3.special_msg_pv as `专题和大促页-转化点击私信咨询pv`
,concat(round(T2.special_pv/T1.special_pv*100,2),'%') as `专题和大促页-转化pv率`
,concat(round(T2.special_pv/T1.wel_pv*100,2),'%') as `专题和大促页-转化美购pv占比`
,concat(round(T3.special_add_pv/T2.special_pv*100,2),'%') as `专题和大促页-点击加车率`
,concat(round(T3.special_buy_pv/T2.special_pv*100,2),'%') as `专题和大促页-点击立即支付率`
,concat(round(T3.special_msg_pv/T2.special_pv*100,2),'%') as `专题和大促页-点击私信咨询率`
,T1.expert_detail_pv as `医生主页pv`
,T2.expert_detail_pv as `医生主页-转化pv`
,T3.exp_add_pv as `医生主页-转化点击加车pv`
,T3.exp_buy_pv as `医生主页-转化点击立即支付pv`
,T3.exp_msg_pv as `医生主页-转化点击私信咨询pv`
,concat(round(T2.expert_detail_pv/T1.expert_detail_pv*100,2),'%') as `医生主页-转化pv率`
,concat(round(T2.expert_detail_pv/T1.wel_pv*100,2),'%') as `医生主页-转化美购pv占比`
,concat(round(T3.exp_add_pv/T2.expert_detail_pv*100,2),'%') as `医生主页-点击加车率`
,concat(round(T3.exp_buy_pv/T2.expert_detail_pv*100,2),'%') as `医生主页-点击立即支付率`
,concat(round(T3.exp_msg_pv/T2.expert_detail_pv*100,2),'%') as `医生主页-点击私信咨询率`
,T1.wel_pv as `美购详情页pv`
,T2.wel_pv as `其他美购详情页-转化pv`
,T3.wel_add_pv as `其他美购详情页-转化点击加车pv`
,T3.wel_buy_pv as `其他美购详情页-转化点击立即支付pv`
,T3.wel_msg_pv as `其他美购详情页-转化点击私信咨询pv`
,concat(round(T2.wel_pv/T1.wel_pv*100,2),'%') as `其他美购详情页-转化pv率`
,concat(round(T2.wel_pv/T1.wel_pv*100,2),'%') as `其他美购详情页-转化美购pv占比`
,concat(round(T3.wel_add_pv/T2.wel_pv*100,2),'%') as `其他美购详情页-点击加车率`
,concat(round(T3.wel_buy_pv/T2.wel_pv*100,2),'%') as `其他美购详情页-点击立即支付率`
,concat(round(T3.wel_msg_pv/T2.wel_pv*100,2),'%') as `其他美购详情页-点击私信咨询率`
,T1.welfare_home_pv as `美购首页pv`
,T2.welfare_home_pv as `美购首页-转化pv`
,T3.wel_home_add_pv as `美购首页-转化点击加车pv`
,T3.wel_home_buy_pv as `美购首页-转化点击立即支付pv`
,T3.wel_home_msg_pv as `美购首页-转化点击私信咨询pv`
,concat(round(T2.welfare_home_pv/T1.welfare_home_pv*100,2),'%') as `美购首页-转化pv率`
,concat(round(T2.welfare_home_pv/T1.wel_pv*100,2),'%') as `美购首页-转化美购pv占比`
,concat(round(T3.wel_home_add_pv/T2.welfare_home_pv*100,2),'%') as `美购首页-点击加车率`
,concat(round(T3.wel_home_buy_pv/T2.welfare_home_pv*100,2),'%') as `美购首页-点击立即支付率`
,concat(round(T3.wel_home_msg_pv/T2.welfare_home_pv*100,2),'%') as `美购首页-点击私信咨询率`
,T1.diary_detail_pv as `日记本详情页pv`
,T2.diary_detail_pv as `日记本详情页-转化pv`
,T3.diary_add_pv as `日记本详情页-转化点击加车pv`
,T3.diary_buy_pv as `日记本详情页-转化点击立即支付pv`
,T3.diary_msg_pv as `日记本详情页-转化点击私信咨询pv`
,concat(round(T2.diary_detail_pv/T1.diary_detail_pv*100,2),'%') as `日记本详情页-转化pv率`
,concat(round(T2.diary_detail_pv/T1.wel_pv*100,2),'%') as `日记本详情页-转化美购pv占比`
,concat(round(T3.diary_add_pv/T2.diary_detail_pv*100,2),'%') as `日记本详情页-点击加车率`
,concat(round(T3.diary_buy_pv/T2.diary_detail_pv*100,2),'%') as `日记本详情页-点击立即支付率`
,concat(round(T3.diary_msg_pv/T2.diary_detail_pv*100,2),'%') as `日记本详情页-点击私信咨询率`
,T1.sign_pv as `签到页pv`
,T2.sign_pv as `签到页-转化pv`
,T3.sign_add_pv as `签到页-转化点击加车pv`
,T3.sign_buy_pv as `签到页-转化点击立即支付pv`
,T3.sign_msg_pv as `签到页-转化点击私信咨询pv`
,concat(round(T2.sign_pv/T1.sign_pv*100,2),'%') as `签到页-转化pv率`
,concat(round(T2.sign_pv/T1.wel_pv*100,2),'%') as `签到页-转化美购pv占比`
,concat(round(T3.sign_add_pv/T2.sign_pv*100,2),'%') as `签到页-点击加车率`
,concat(round(T3.sign_buy_pv/T2.sign_pv*100,2),'%') as `签到页-点击立即支付率`
,concat(round(T3.sign_msg_pv/T2.sign_pv*100,2),'%') as `签到页-点击私信咨询率`
,T1.ai_report_pv as `AI结果页pv`
,T2.ai_report_pv as `AI结果页-转化pv`
,T3.ai_add_pv as `AI结果页-转化点击加车pv`
,T3.ai_buy_pv as `AI结果页-转化点击立即支付pv`
,T3.ai_msg_pv as `AI结果页-转化点击私信咨询pv`
,concat(round(T2.ai_report_pv/T1.ai_report_pv*100,2),'%') as `AI结果页-转化pv率`
,concat(round(T2.ai_report_pv/T1.wel_pv*100,2),'%') as `AI结果页-转化美购pv占比`
,concat(round(T3.ai_add_pv/T2.ai_report_pv*100,2),'%') as `AI结果页-点击加车率`
,concat(round(T3.ai_buy_pv/T2.ai_report_pv*100,2),'%') as `AI结果页-点击立即支付率`
,concat(round(T3.ai_msg_pv/T2.ai_report_pv*100,2),'%') as `AI结果页-点击私信咨询率`
,T1.zone_pv as `内容聚合页pv`
,T2.zone_pv as `内容聚合页-转化pv`
,T3.zone_add_pv as `内容聚合页-转化点击加车pv`
,T3.zone_buy_pv as `内容聚合页-转化点击立即支付pv`
,T3.zone_msg_pv as `内容聚合页-转化点击私信咨询pv`
,concat(round(T2.zone_pv/T1.zone_pv*100,2),'%') as `内容聚合页-转化pv率`
,concat(round(T2.zone_pv/T1.wel_pv*100,2),'%') as `内容聚合页-转化美购pv占比`
,concat(round(T3.zone_add_pv/T2.zone_pv*100,2),'%') as `内容聚合页-点击加车率`
,concat(round(T3.zone_buy_pv/T2.zone_pv*100,2),'%') as `内容聚合页-点击立即支付率`
,concat(round(T3.zone_msg_pv/T2.zone_pv*100,2),'%') as `内容聚合页-点击私信咨询率`
FROM
(--能够走向美购详情页的各页面pv/uv
(--能够走向美购详情页的各页面pv/uv
SELECT t1.partition_date
,t1.device_os_type
,t1.device_type
,t1.active_type
,t2.channel
,count(case when page_name = 'welfare_detail' then t1.cl_id end) as wel_pv
......@@ -189,67 +191,68 @@ FROM
,count(case when page_name = 'diary_detail' then t1.cl_id end) as diary_detail_pv
,count(case when page_name = 'order_detail' then t1.cl_id end) as order_detail_pv
,count(case when page_name ='new_sign' then t1.cl_id end) as sign_pv
,count(case when page_name in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion') then t1.cl_id end) as special_pv --专题和大促
,count(case when page_name in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion','custom_special') then t1.cl_id end) as special_pv --专题和大促
,count(case when page_name = 'zone_v3' then t1.cl_id end) as zone_pv
,count(case when page_name in ('report_result','face_detect_result') then t1.cl_id end) as ai_report_pv --待之后增加模拟整形页面
FROM
(
SELECT t1.partition_date,t1.page_name,t1.cl_id,mas.device_os_type,mas.active_type,mas.channel
SELECT t1.partition_date,t1.page_name,t1.cl_id,mas.device_type,mas.active_type,mas.channel
FROM
(
SELECT partition_date,page_name,cl_id
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >=regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >=regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='page_view'
)t1
JOIN
(
SELECT
partition_date
,m.device_id, device_os_type
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
SELECT partition_date,device_os_type as device_type,m.device_id
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL
or first_channel_source_type in ('promotion_aisi','promotion_koomobi_km00','promotion_koomobi_km01')
or first_channel_source_type like '%longyuzhixing%' or first_channel_source_type like '%jingmeng%'
or first_channel_source_type like '%mailuo%' THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
)mas
ON t1.cl_id=mas.device_id
AND t1.partition_date=mas.partition_date
LEFT JOIN
(
( -- 去掉疑似机构刷量的PV和UV
SELECT cl_id
FROM online.ml_hospital_spam_pv_day
FROM ml_hospital_spam_pv_day
WHERE partition_date>='20180402' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
UNION ALL
SELECT cl_id
FROM online.ml_hospital_spam_pv_month
FROM ml_hospital_spam_pv_month
WHERE partition_date>='20171101' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
)spam_pv
......@@ -257,12 +260,12 @@ FROM
WHERE spam_pv.cl_id IS NULL
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_os_type,t1.active_type,t2.channel
GROUP BY t1.partition_date,t1.device_type,t1.active_type,t2.channel
)T1
LEFT JOIN
(--不同referrer下的美购详情页pv/uv
LEFT JOIN
(--不同referrer下的美购详情页pv/uv
SELECT t1.partition_date
,t1.device_os_type
,t1.device_type
,t1.active_type
,t2.channel
,count(case when referrer = 'welfare_detail' then t1.cl_id end) as wel_pv
......@@ -278,67 +281,68 @@ FROM
,count(case when referrer = 'diary_detail' then t1.cl_id end) as diary_detail_pv
,count(case when referrer = 'order_detail' then t1.cl_id end) as order_detail_pv
,count(case when referrer ='new_sign' then t1.cl_id end) as sign_pv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion') then t1.cl_id end) as special_pv --专题和大促
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion','custom_special') then t1.cl_id end) as special_pv --专题和大促
,count(case when referrer = 'zone_v3' then t1.cl_id end) as zone_pv
,count(case when referrer in ('report_result','face_detect_result') then t1.cl_id end) as ai_report_pv --待之后增加模拟整形页面
FROM
(
SELECT t1.partition_date,t1.referrer,t1.cl_id,mas.device_os_type,mas.active_type,mas.channel
SELECT t1.partition_date,t1.referrer,t1.cl_id,mas.device_type,mas.active_type,mas.channel
FROM
(
SELECT partition_date,referrer,cl_id
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='page_view'
)t1
JOIN
(
SELECT
partition_date
,m.device_id, device_os_type
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
SELECT partition_date,device_os_type as device_type,m.device_id
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL
or first_channel_source_type in ('promotion_aisi','promotion_koomobi_km00','promotion_koomobi_km01')
or first_channel_source_type like '%longyuzhixing%' or first_channel_source_type like '%jingmeng%'
or first_channel_source_type like '%mailuo%' THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
)mas
ON t1.cl_id=mas.device_id
AND t1.partition_date=mas.partition_date
LEFT JOIN
(
( -- 去掉疑似机构刷量的PV和UV
SELECT cl_id
FROM online.ml_hospital_spam_pv_day
FROM ml_hospital_spam_pv_day
WHERE partition_date>='20180402' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
UNION ALL
SELECT cl_id
FROM online.ml_hospital_spam_pv_month
FROM ml_hospital_spam_pv_month
WHERE partition_date>='20171101' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
)spam_pv
......@@ -346,16 +350,16 @@ FROM
WHERE spam_pv.cl_id IS NULL
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_os_type,t1.active_type,t2.channel
GROUP BY t1.partition_date,t1.device_type,t1.active_type,t2.channel
)T2
ON T1.partition_date=T2.partition_date
and T1.device_os_type=T2.device_os_type
AND T1.active_type=T2.active_type
AND T1.channel=T2.channel
LEFT JOIN
(--点击加车/支付/私信的不同来源
ON T1.partition_date=T2.partition_date
and T1.device_type=T2.device_type
AND T1.active_type=T2.active_type
AND T1.channel=T2.channel
LEFT JOIN
(--点击加车/支付/私信的不同来源
SELECT t1.partition_date
,t1.device_os_type
,t1.device_type
,t1.active_type
,t2.channel
,count(case when referrer = 'welfare_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as wel_add_pv
......@@ -397,9 +401,9 @@ FROM
,count(case when referrer = 'new_sign' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as sign_add_pv
,count(case when referrer = 'new_sign' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as sign_buy_pv
,count(case when referrer = 'new_sign' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as sign_msg_pv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion') and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as special_add_pv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion') and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as special_buy_pv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion') and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as special_msg_pv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion','custom_special') and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as special_add_pv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion','custom_special') and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as special_buy_pv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion','custom_special') and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as special_msg_pv
,count(case when referrer = 'zone_v3' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as zone_add_pv
,count(case when referrer = 'zone_v3' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as zone_buy_pv
,count(case when referrer = 'zone_v3' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as zone_msg_pv
......@@ -409,12 +413,12 @@ FROM
FROM
(
SELECT t1.partition_date,t1.referrer,t1.action,t1.cl_id,mas.device_os_type,mas.active_type,mas.channel
SELECT t1.partition_date,t1.referrer,t1.action,t1.cl_id,mas.device_type,mas.active_type,mas.channel
FROM
( --点击加车/支付
SELECT partition_date,referrer,action,cl_id
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >=regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >=regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action in ('welfare_multiattribute_click_add','welfare_multiattribute_click_buy')
......@@ -423,58 +427,80 @@ FROM
--点击私信按钮
SELECT partition_date,referrer,action,cl_id
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >=regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >=regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_message'
UNION ALL
--点击私信区域(目前referrer缺失,故通过拆解referrer_link的方式获得)
SELECT partition_date,referrer,action,cl_id
FROM
(
SELECT partition_date,cl_id,action,t2.referrer as referrer
,row_number () over (PARTITION BY t1.referrer_link,t1.cl_id ORDER BY t2.link_id desc) as rank
from
( SELECT partition_date,params['referrer_link'] as referrer_link,cl_id,action
,json_split(params['referrer_link'],'string') as a
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
AND params['button_name'] in ('question_tag','appointment')
)t1
lateral view posexplode(a) t2 as link_id,referrer
)t3
where rank=1
)t1
JOIN
(
SELECT
partition_date
,m.device_id, device_os_type
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
SELECT partition_date,device_os_type as device_type,m.device_id
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL
or first_channel_source_type in ('promotion_aisi','promotion_koomobi_km00','promotion_koomobi_km01')
or first_channel_source_type like '%longyuzhixing%' or first_channel_source_type like '%jingmeng%'
or first_channel_source_type like '%mailuo%' THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
)mas
ON t1.cl_id=mas.device_id
AND t1.partition_date=mas.partition_date
LEFT JOIN
( -- 去掉疑似机构刷量的PV和UV
SELECT cl_id
FROM online.ml_hospital_spam_pv_day
FROM ml_hospital_spam_pv_day
WHERE partition_date>='20180402' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
UNION ALL
SELECT cl_id
FROM online.ml_hospital_spam_pv_month
FROM ml_hospital_spam_pv_month
WHERE partition_date>='20171101' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
)spam_pv
......@@ -482,10 +508,11 @@ FROM
WHERE spam_pv.cl_id IS NULL
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_os_type,t1.active_type,t2.channel
GROUP BY t1.partition_date,t1.device_type,t1.active_type,t2.channel
)T3
ON T1.partition_date=T3.partition_date
and T1.device_os_type=T3.device_os_type
AND T1.active_type=T3.active_type
AND T1.channel=T3.channel
ORDER BY `日期` desc,`设备类型`,`活跃类型`,`渠道`
\ No newline at end of file
ON T1.partition_date=T3.partition_date
and T1.device_type=T3.device_type
AND T1.active_type=T3.active_type
AND T1.channel=T3.channel
ORDER BY `日期` desc,`设备类型`,`活跃类型`,`渠道`
--美购详情页的来源
SELECT T1.partition_date as `日期`
,T1.device_os_type as `设备类型`
,T1.active_type as `活跃类型`
,T1.channel as `渠道`
,T1.wel_uv as `美购详情页uv`
,T1.search_result_welfare_uv as `搜索结果美购页uv`
,T2.search_result_welfare_uv as `搜索结果美购页-转化uv`
,T3.result_wel_add_uv as `搜索结果美购页-转化点击加车uv`
,T3.result_wel_buy_uv as `搜索结果美购页-转化点击立即支付uv`
,T3.result_wel_msg_uv as `搜索结果美购页-转化点击私信咨询uv`
,concat(round(T2.search_result_welfare_uv/T1.search_result_welfare_uv*100,2),'%') as `搜索结果美购页-转化uv率`
,concat(round(T2.search_result_welfare_uv/T1.wel_uv*100,2),'%') as `搜索结果美购页-转化美购uv占比`
,concat(round(T3.result_wel_add_uv/T2.search_result_welfare_uv*100,2),'%') as `搜索结果美购页-点击加车率`
,concat(round(T3.result_wel_buy_uv/T2.search_result_welfare_uv*100,2),'%') as `搜索结果美购页-点击立即支付率`
,concat(round(T3.result_wel_msg_uv/T2.search_result_welfare_uv*100,2),'%') as `搜索结果美购页-点击私信咨询率`
,T1.welfare_list_uv as `美购列表页uv`
,T2.welfare_list_uv as `美购列表页-转化uv`
,T3.wel_list_add_uv as `美购列表页-转化点击加车uv`
,T3.wel_list_buy_uv as `美购列表页-转化点击立即支付uv`
,T3.wel_list_msg_uv as `美购列表页-转化点击私信咨询uv`
,concat(round(T2.welfare_list_uv/T1.welfare_list_uv*100,2),'%') as `美购列表页-转化uv率`
,concat(round(T2.welfare_list_uv/T1.wel_uv*100,2),'%') as `美购列表页-转化美购uv占比`
,concat(round(T3.wel_list_add_uv/T2.welfare_list_uv*100,2),'%') as `美购列表页-点击加车率`
,concat(round(T3.wel_list_buy_uv/T2.welfare_list_uv*100,2),'%') as `美购列表页-点击立即支付率`
,concat(round(T3.wel_list_msg_uv/T2.welfare_list_uv*100,2),'%') as `美购列表页-点击私信咨询率`
,T1.organization_detail_uv as `医院主页uv`
,T2.organization_detail_uv as `医院主页-转化uv`
,T3.org_add_uv as `医院主页-转化点击加车uv`
,T3.org_buy_uv as `医院主页-转化点击立即支付uv`
,T3.org_msg_uv as `医院主页-转化点击私信咨询uv`
,concat(round(T2.organization_detail_uv/T1.organization_detail_uv*100,2),'%') as `医院主页-转化uv率`
,concat(round(T2.organization_detail_uv/T1.wel_uv*100,2),'%') as `医院主页-转化美购uv占比`
,concat(round(T3.org_add_uv/T2.organization_detail_uv*100,2),'%') as `医院主页-点击加车率`
,concat(round(T3.org_buy_uv/T2.organization_detail_uv*100,2),'%') as `医院主页-点击立即支付率`
,concat(round(T3.org_msg_uv/T2.organization_detail_uv*100,2),'%') as `医院主页-点击私信咨询率`
,T1.category_uv as `品类聚合页uv`
,T2.category_uv as `品类聚合页-转化uv`
,T3.category_add_uv as `品类聚合页-转化点击加车uv`
,T3.category_buy_uv as `品类聚合页-转化点击立即支付uv`
,T3.category_msg_uv as `品类聚合页-转化点击私信咨询uv`
,concat(round(T2.category_uv/T1.category_uv*100,2),'%') as `品类聚合页-转化uv率`
,concat(round(T2.category_uv/T1.wel_uv*100,2),'%') as `品类聚合页-转化美购uv占比`
,concat(round(T3.category_add_uv/T2.category_uv*100,2),'%') as `品类聚合页-点击加车率`
,concat(round(T3.category_buy_uv/T2.category_uv*100,2),'%') as `品类聚合页-点击立即支付率`
,concat(round(T3.category_msg_uv/T2.category_uv*100,2),'%') as `品类聚合页-点击私信咨询率`
,T1.sign_uv as `签到页uv`
,T2.sign_uv as `签到页-转化uv`
,T3.sign_add_uv as `签到页-转化点击加车uv`
,T3.sign_buy_uv as `签到页-转化点击立即支付uv`
,T3.sign_msg_uv as `签到页-转化点击私信咨询uv`
,concat(round(T2.sign_uv/T1.sign_uv*100,2),'%') as `签到页-转化uv率`
,concat(round(T2.sign_uv/T1.wel_uv*100,2),'%') as `签到页-转化美购uv占比`
,concat(round(T3.sign_add_uv/T2.sign_uv*100,2),'%') as `签到页-点击加车率`
,concat(round(T3.sign_buy_uv/T2.sign_uv*100,2),'%') as `签到页-点击立即支付率`
,concat(round(T3.sign_msg_uv/T2.sign_uv*100,2),'%') as `签到页-点击私信咨询率`
,T1.special_uv as `专题和大促页uv`
,T2.special_uv as `专题和大促页-转化uv`
,T3.special_add_uv as `专题和大促页-转化点击加车uv`
,T3.special_buy_uv as `专题和大促页-转化点击立即支付uv`
,T3.special_msg_uv as `专题和大促页-转化点击私信咨询uv`
,concat(round(T2.special_uv/T1.special_uv*100,2),'%') as `专题和大促页-转化uv率`
,concat(round(T2.special_uv/T1.wel_uv*100,2),'%') as `专题和大促页-转化美购uv占比`
,concat(round(T3.special_add_uv/T2.special_uv*100,2),'%') as `专题和大促页-点击加车率`
,concat(round(T3.special_buy_uv/T2.special_uv*100,2),'%') as `专题和大促页-点击立即支付率`
,concat(round(T3.special_msg_uv/T2.special_uv*100,2),'%') as `专题和大促页-点击私信咨询率`
,T1.my_cart_uv as`购物车uv`
,T2.my_cart_uv as`购物车-转化uv`
,T3.cart_add_uv as `购物车-转化点击加车uv`
,T3.cart_buy_uv as `购物车-转化点击立即支付uv`
,T3.cart_msg_uv as `购物车-转化点击私信咨询uv`
,concat(round(T2.my_cart_uv/T1.my_cart_uv*100,2),'%') as `购物车-转化uv率`
,concat(round(T2.my_cart_uv/T1.wel_uv*100,2),'%') as `购物车-转化美购uv占比`
,concat(round(T3.cart_add_uv/T2.my_cart_uv*100,2),'%') as `购物车-点击加车率`
,concat(round(T3.cart_buy_uv/T2.my_cart_uv*100,2),'%') as `购物车-点击立即支付率`
,concat(round(T3.cart_msg_uv/T2.my_cart_uv*100,2),'%') as `购物车-点击私信咨询率`
,T1.search_result_more_uv as `搜索结果综合页uv`
,T2.search_result_more_uv as `搜索结果综合页-转化uv`
,T3.result_more_add_uv as `搜索结果综合页-转化点击加车uv`
,T3.result_more_buy_uv as `搜索结果综合页-转化点击立即支付uv`
,T3.result_more_msg_uv as `搜索结果综合页-转化点击私信咨询uv`
,concat(round(T2.search_result_more_uv/T1.search_result_more_uv*100,2),'%') as `搜索结果综合页-转化uv率`
,concat(round(T2.search_result_more_uv/T1.wel_uv*100,2),'%') as `搜索结果综合页-转化美购uv占比`
,concat(round(T3.result_more_add_uv/T2.search_result_more_uv*100,2),'%') as `搜索结果综合页-点击加车率`
,concat(round(T3.result_more_buy_uv/T2.search_result_more_uv*100,2),'%') as `搜索结果综合页-点击立即支付率`
,concat(round(T3.result_more_msg_uv/T2.search_result_more_uv*100,2),'%') as `搜索结果综合页-点击私信咨询率`
,T1.welfare_home_uv as `美购首页uv`
,T2.welfare_home_uv as `美购首页-转化uv`
,T3.wel_home_add_uv as `美购首页-转化点击加车uv`
,T3.wel_home_buy_uv as `美购首页-转化点击立即支付uv`
,T3.wel_home_msg_uv as `美购首页-转化点击私信咨询uv`
,concat(round(T2.welfare_home_uv/T1.welfare_home_uv*100,2),'%') as `美购首页-转化uv率`
,concat(round(T2.welfare_home_uv/T1.wel_uv*100,2),'%') as `美购首页-转化美购uv占比`
,concat(round(T3.wel_home_add_uv/T2.welfare_home_uv*100,2),'%') as `美购首页-点击加车率`
,concat(round(T3.wel_home_buy_uv/T2.welfare_home_uv*100,2),'%') as `美购首页-点击立即支付率`
,concat(round(T3.wel_home_msg_uv/T2.welfare_home_uv*100,2),'%') as `美购首页-点击私信咨询率`
,T1.conversation_detail_uv as `私信详情页uv`
,T2.conversation_detail_uv as `私信详情页-转化uv`
,T3.conv_add_uv as `私信详情页-转化点击加车uv`
,T3.conv_buy_uv as `私信详情页-转化点击立即支付uv`
,T3.conv_msg_uv as `私信详情页-转化点击私信咨询uv`
,concat(round(T2.conversation_detail_uv/T1.conversation_detail_uv*100,2),'%') as `私信详情页-转化uv率`
,concat(round(T2.conversation_detail_uv/T1.wel_uv*100,2),'%') as `私信详情页-转化美购uv占比`
,concat(round(T3.conv_add_uv/T2.conversation_detail_uv*100,2),'%') as `私信详情页-点击加车率`
,concat(round(T3.conv_buy_uv/T2.conversation_detail_uv*100,2),'%') as `私信详情页-点击立即支付率`
,concat(round(T3.conv_msg_uv/T2.conversation_detail_uv*100,2),'%') as `私信详情页-点击私信咨询率`
,T1.wel_uv as `美购详情页uv`
,T2.wel_uv as `其他美购详情页-转化uv`
,T3.wel_add_uv as `其他美购详情页-转化点击加车uv`
,T3.wel_buy_uv as `其他美购详情页-转化点击立即支付uv`
,T3.wel_msg_uv as `其他美购详情页-转化点击私信咨询uv`
,concat(round(T2.wel_uv/T1.wel_uv*100,2),'%') as `其他美购详情页-转化uv率`
,concat(round(T2.wel_uv/T1.wel_uv*100,2),'%') as `其他美购详情页-转化美购uv占比`
,concat(round(T3.wel_add_uv/T2.wel_uv*100,2),'%') as `其他美购详情页-点击加车率`
,concat(round(T3.wel_buy_uv/T2.wel_uv*100,2),'%') as `其他美购详情页-点击立即支付率`
,concat(round(T3.wel_msg_uv/T2.wel_uv*100,2),'%') as `其他美购详情页-点击私信咨询率`
,T1.order_detail_uv as `订单详情页uv`
,T2.order_detail_uv as `订单详情页-转化uv`
,T3.order_add_uv as `订单详情页-转化点击加车uv`
,T3.order_buy_uv as `订单详情页-转化点击立即支付uv`
,T3.order_msg_uv as `订单详情页-转化点击私信咨询uv`
,concat(round(T2.order_detail_uv/T1.order_detail_uv*100,2),'%') as `订单详情页-转化uv率`
,concat(round(T2.order_detail_uv/T1.wel_uv*100,2),'%') as `订单详情页-转化美购uv占比`
,concat(round(T3.order_add_uv/T2.order_detail_uv*100,2),'%') as `订单详情页-点击加车率`
,concat(round(T3.order_buy_uv/T2.order_detail_uv*100,2),'%') as `订单详情页-点击立即支付率`
,concat(round(T3.order_msg_uv/T2.order_detail_uv*100,2),'%') as `订单详情页-点击私信咨询率`
,T1.expert_detail_uv as `医生主页uv`
,T2.expert_detail_uv as `医生主页-转化uv`
,T3.exp_add_uv as `医生主页-转化点击加车uv`
,T3.exp_buy_uv as `医生主页-转化点击立即支付uv`
,T3.exp_msg_uv as `医生主页-转化点击私信咨询uv`
,concat(round(T2.expert_detail_uv/T1.expert_detail_uv*100,2),'%') as `医生主页-转化uv率`
,concat(round(T2.expert_detail_uv/T1.wel_uv*100,2),'%') as `医生主页-转化美购uv占比`
,concat(round(T3.exp_add_uv/T2.expert_detail_uv*100,2),'%') as `医生主页-点击加车率`
,concat(round(T3.exp_buy_uv/T2.expert_detail_uv*100,2),'%') as `医生主页-点击立即支付率`
,concat(round(T3.exp_msg_uv/T2.expert_detail_uv*100,2),'%') as `医生主页-点击私信咨询率`
,T1.ai_report_uv as `AI结果页uv`
,T2.ai_report_uv as `AI结果页-转化uv`
,T3.ai_add_uv as `AI结果页-转化点击加车uv`
,T3.ai_buy_uv as `AI结果页-转化点击立即支付uv`
,T3.ai_msg_uv as `AI结果页-转化点击私信咨询uv`
,concat(round(T2.ai_report_uv/T1.ai_report_uv*100,2),'%') as `AI结果页-转化uv率`
,concat(round(T2.ai_report_uv/T1.wel_uv*100,2),'%') as `AI结果页-转化美购uv占比`
,concat(round(T3.ai_add_uv/T2.ai_report_uv*100,2),'%') as `AI结果页-点击加车率`
,concat(round(T3.ai_buy_uv/T2.ai_report_uv*100,2),'%') as `AI结果页-点击立即支付率`
,concat(round(T3.ai_msg_uv/T2.ai_report_uv*100,2),'%') as `AI结果页-点击私信咨询率`
,T1.diary_detail_uv as `日记本详情页uv`
,T2.diary_detail_uv as `日记本详情页-转化uv`
,T3.diary_add_uv as `日记本详情页-转化点击加车uv`
,T3.diary_buy_uv as `日记本详情页-转化点击立即支付uv`
,T3.diary_msg_uv as `日记本详情页-转化点击私信咨询uv`
,concat(round(T2.diary_detail_uv/T1.diary_detail_uv*100,2),'%') as `日记本详情页-转化uv率`
,concat(round(T2.diary_detail_uv/T1.wel_uv*100,2),'%') as `日记本详情页-转化美购uv占比`
,concat(round(T3.diary_add_uv/T2.diary_detail_uv*100,2),'%') as `日记本详情页-点击加车率`
,concat(round(T3.diary_buy_uv/T2.diary_detail_uv*100,2),'%') as `日记本详情页-点击立即支付率`
,concat(round(T3.diary_msg_uv/T2.diary_detail_uv*100,2),'%') as `日记本详情页-点击私信咨询率`
,T1.zone_uv as `内容聚合页uv`
,T2.zone_uv as `内容聚合页-转化uv`
,T3.zone_add_uv as `内容聚合页-转化点击加车uv`
,T3.zone_buy_uv as `内容聚合页-转化点击立即支付uv`
,T3.zone_msg_uv as `内容聚合页-转化点击私信咨询uv`
,concat(round(T2.zone_uv/T1.zone_uv*100,2),'%') as `内容聚合页-转化uv率`
,concat(round(T2.zone_uv/T1.wel_uv*100,2),'%') as `内容聚合页-转化美购uv占比`
,concat(round(T3.zone_add_uv/T2.zone_uv*100,2),'%') as `内容聚合页-点击加车率`
,concat(round(T3.zone_buy_uv/T2.zone_uv*100,2),'%') as `内容聚合页-点击立即支付率`
,concat(round(T3.zone_msg_uv/T2.zone_uv*100,2),'%') as `内容聚合页-点击私信咨询率`
,T1.device_type as `设备类型`
,T1.active_type as `活跃类型`
,T1.channel as `渠道`
,T1.wel_uv as `美购详情页uv`
,T1.search_result_welfare_uv as `搜索结果美购页uv`
,T2.search_result_welfare_uv as `搜索结果美购页-转化uv`
,T3.result_wel_add_uv as `搜索结果美购页-转化点击加车uv`
,T3.result_wel_buy_uv as `搜索结果美购页-转化点击立即支付uv`
,T3.result_wel_msg_uv as `搜索结果美购页-转化点击私信咨询uv`
,concat(round(T2.search_result_welfare_uv/T1.search_result_welfare_uv*100,2),'%') as `搜索结果美购页-转化uv率`
,concat(round(T2.search_result_welfare_uv/T1.wel_uv*100,2),'%') as `搜索结果美购页-转化美购uv占比`
,concat(round(T3.result_wel_add_uv/T2.search_result_welfare_uv*100,2),'%') as `搜索结果美购页-点击加车率`
,concat(round(T3.result_wel_buy_uv/T2.search_result_welfare_uv*100,2),'%') as `搜索结果美购页-点击立即支付率`
,concat(round(T3.result_wel_msg_uv/T2.search_result_welfare_uv*100,2),'%') as `搜索结果美购页-点击私信咨询率`
,T1.organization_detail_uv as `医院主页uv`
,T2.organization_detail_uv as `医院主页-转化uv`
,T3.org_add_uv as `医院主页-转化点击加车uv`
,T3.org_buy_uv as `医院主页-转化点击立即支付uv`
,T3.org_msg_uv as `医院主页-转化点击私信咨询uv`
,concat(round(T2.organization_detail_uv/T1.organization_detail_uv*100,2),'%') as `医院主页-转化uv率`
,concat(round(T2.organization_detail_uv/T1.wel_uv*100,2),'%') as `医院主页-转化美购uv占比`
,concat(round(T3.org_add_uv/T2.organization_detail_uv*100,2),'%') as `医院主页-点击加车率`
,concat(round(T3.org_buy_uv/T2.organization_detail_uv*100,2),'%') as `医院主页-点击立即支付率`
,concat(round(T3.org_msg_uv/T2.organization_detail_uv*100,2),'%') as `医院主页-点击私信咨询率`
,T1.category_uv as `品类聚合页uv`
,T2.category_uv as `品类聚合页-转化uv`
,T3.category_add_uv as `品类聚合页-转化点击加车uv`
,T3.category_buy_uv as `品类聚合页-转化点击立即支付uv`
,T3.category_msg_uv as `品类聚合页-转化点击私信咨询uv`
,concat(round(T2.category_uv/T1.category_uv*100,2),'%') as `品类聚合页-转化uv率`
,concat(round(T2.category_uv/T1.wel_uv*100,2),'%') as `品类聚合页-转化美购uv占比`
,concat(round(T3.category_add_uv/T2.category_uv*100,2),'%') as `品类聚合页-点击加车率`
,concat(round(T3.category_buy_uv/T2.category_uv*100,2),'%') as `品类聚合页-点击立即支付率`
,concat(round(T3.category_msg_uv/T2.category_uv*100,2),'%') as `品类聚合页-点击私信咨询率`
,T1.conversation_detail_uv as `私信详情页uv`
,T2.conversation_detail_uv as `私信详情页-转化uv`
,T3.conv_add_uv as `私信详情页-转化点击加车uv`
,T3.conv_buy_uv as `私信详情页-转化点击立即支付uv`
,T3.conv_msg_uv as `私信详情页-转化点击私信咨询uv`
,concat(round(T2.conversation_detail_uv/T1.conversation_detail_uv*100,2),'%') as `私信详情页-转化uv率`
,concat(round(T2.conversation_detail_uv/T1.wel_uv*100,2),'%') as `私信详情页-转化美购uv占比`
,concat(round(T3.conv_add_uv/T2.conversation_detail_uv*100,2),'%') as `私信详情页-点击加车率`
,concat(round(T3.conv_buy_uv/T2.conversation_detail_uv*100,2),'%') as `私信详情页-点击立即支付率`
,concat(round(T3.conv_msg_uv/T2.conversation_detail_uv*100,2),'%') as `私信详情页-点击私信咨询率`
,T1.welfare_list_uv as `美购列表页uv`
,T2.welfare_list_uv as `美购列表页-转化uv`
,T3.wel_list_add_uv as `美购列表页-转化点击加车uv`
,T3.wel_list_buy_uv as `美购列表页-转化点击立即支付uv`
,T3.wel_list_msg_uv as `美购列表页-转化点击私信咨询uv`
,concat(round(T2.welfare_list_uv/T1.welfare_list_uv*100,2),'%') as `美购列表页-转化uv率`
,concat(round(T2.welfare_list_uv/T1.wel_uv*100,2),'%') as `美购列表页-转化美购uv占比`
,concat(round(T3.wel_list_add_uv/T2.welfare_list_uv*100,2),'%') as `美购列表页-点击加车率`
,concat(round(T3.wel_list_buy_uv/T2.welfare_list_uv*100,2),'%') as `美购列表页-点击立即支付率`
,concat(round(T3.wel_list_msg_uv/T2.welfare_list_uv*100,2),'%') as `美购列表页-点击私信咨询率`
,T1.my_cart_uv as`购物车uv`
,T2.my_cart_uv as`购物车-转化uv`
,T3.cart_add_uv as `购物车-转化点击加车uv`
,T3.cart_buy_uv as `购物车-转化点击立即支付uv`
,T3.cart_msg_uv as `购物车-转化点击私信咨询uv`
,concat(round(T2.my_cart_uv/T1.my_cart_uv*100,2),'%') as `购物车-转化uv率`
,concat(round(T2.my_cart_uv/T1.wel_uv*100,2),'%') as `购物车-转化美购uv占比`
,concat(round(T3.cart_add_uv/T2.my_cart_uv*100,2),'%') as `购物车-点击加车率`
,concat(round(T3.cart_buy_uv/T2.my_cart_uv*100,2),'%') as `购物车-点击立即支付率`
,concat(round(T3.cart_msg_uv/T2.my_cart_uv*100,2),'%') as `购物车-点击私信咨询率`
,T1.search_result_more_uv as `搜索结果综合页uv`
,T2.search_result_more_uv as `搜索结果综合页-转化uv`
,T3.result_more_add_uv as `搜索结果综合页-转化点击加车uv`
,T3.result_more_buy_uv as `搜索结果综合页-转化点击立即支付uv`
,T3.result_more_msg_uv as `搜索结果综合页-转化点击私信咨询uv`
,concat(round(T2.search_result_more_uv/T1.search_result_more_uv*100,2),'%') as `搜索结果综合页-转化uv率`
,concat(round(T2.search_result_more_uv/T1.wel_uv*100,2),'%') as `搜索结果综合页-转化美购uv占比`
,concat(round(T3.result_more_add_uv/T2.search_result_more_uv*100,2),'%') as `搜索结果综合页-点击加车率`
,concat(round(T3.result_more_buy_uv/T2.search_result_more_uv*100,2),'%') as `搜索结果综合页-点击立即支付率`
,concat(round(T3.result_more_msg_uv/T2.search_result_more_uv*100,2),'%') as `搜索结果综合页-点击私信咨询率`
,T1.order_detail_uv as `订单详情页uv`
,T2.order_detail_uv as `订单详情页-转化uv`
,T3.order_add_uv as `订单详情页-转化点击加车uv`
,T3.order_buy_uv as `订单详情页-转化点击立即支付uv`
,T3.order_msg_uv as `订单详情页-转化点击私信咨询uv`
,concat(round(T2.order_detail_uv/T1.order_detail_uv*100,2),'%') as `订单详情页-转化uv率`
,concat(round(T2.order_detail_uv/T1.wel_uv*100,2),'%') as `订单详情页-转化美购uv占比`
,concat(round(T3.order_add_uv/T2.order_detail_uv*100,2),'%') as `订单详情页-点击加车率`
,concat(round(T3.order_buy_uv/T2.order_detail_uv*100,2),'%') as `订单详情页-点击立即支付率`
,concat(round(T3.order_msg_uv/T2.order_detail_uv*100,2),'%') as `订单详情页-点击私信咨询率`
,T1.special_uv as `专题和大促页uv`
,T2.special_uv as `专题和大促页-转化uv`
,T3.special_add_uv as `专题和大促页-转化点击加车uv`
,T3.special_buy_uv as `专题和大促页-转化点击立即支付uv`
,T3.special_msg_uv as `专题和大促页-转化点击私信咨询uv`
,concat(round(T2.special_uv/T1.special_uv*100,2),'%') as `专题和大促页-转化uv率`
,concat(round(T2.special_uv/T1.wel_uv*100,2),'%') as `专题和大促页-转化美购uv占比`
,concat(round(T3.special_add_uv/T2.special_uv*100,2),'%') as `专题和大促页-点击加车率`
,concat(round(T3.special_buy_uv/T2.special_uv*100,2),'%') as `专题和大促页-点击立即支付率`
,concat(round(T3.special_msg_uv/T2.special_uv*100,2),'%') as `专题和大促页-点击私信咨询率`
,T1.expert_detail_uv as `医生主页uv`
,T2.expert_detail_uv as `医生主页-转化uv`
,T3.exp_add_uv as `医生主页-转化点击加车uv`
,T3.exp_buy_uv as `医生主页-转化点击立即支付uv`
,T3.exp_msg_uv as `医生主页-转化点击私信咨询uv`
,concat(round(T2.expert_detail_uv/T1.expert_detail_uv*100,2),'%') as `医生主页-转化uv率`
,concat(round(T2.expert_detail_uv/T1.wel_uv*100,2),'%') as `医生主页-转化美购uv占比`
,concat(round(T3.exp_add_uv/T2.expert_detail_uv*100,2),'%') as `医生主页-点击加车率`
,concat(round(T3.exp_buy_uv/T2.expert_detail_uv*100,2),'%') as `医生主页-点击立即支付率`
,concat(round(T3.exp_msg_uv/T2.expert_detail_uv*100,2),'%') as `医生主页-点击私信咨询率`
,T1.wel_uv as `美购详情页uv`
,T2.wel_uv as `其他美购详情页-转化uv`
,T3.wel_add_uv as `其他美购详情页-转化点击加车uv`
,T3.wel_buy_uv as `其他美购详情页-转化点击立即支付uv`
,T3.wel_msg_uv as `其他美购详情页-转化点击私信咨询uv`
,concat(round(T2.wel_uv/T1.wel_uv*100,2),'%') as `其他美购详情页-转化uv率`
,concat(round(T2.wel_uv/T1.wel_uv*100,2),'%') as `其他美购详情页-转化美购uv占比`
,concat(round(T3.wel_add_uv/T2.wel_uv*100,2),'%') as `其他美购详情页-点击加车率`
,concat(round(T3.wel_buy_uv/T2.wel_uv*100,2),'%') as `其他美购详情页-点击立即支付率`
,concat(round(T3.wel_msg_uv/T2.wel_uv*100,2),'%') as `其他美购详情页-点击私信咨询率`
,T1.welfare_home_uv as `美购首页uv`
,T2.welfare_home_uv as `美购首页-转化uv`
,T3.wel_home_add_uv as `美购首页-转化点击加车uv`
,T3.wel_home_buy_uv as `美购首页-转化点击立即支付uv`
,T3.wel_home_msg_uv as `美购首页-转化点击私信咨询uv`
,concat(round(T2.welfare_home_uv/T1.welfare_home_uv*100,2),'%') as `美购首页-转化uv率`
,concat(round(T2.welfare_home_uv/T1.wel_uv*100,2),'%') as `美购首页-转化美购uv占比`
,concat(round(T3.wel_home_add_uv/T2.welfare_home_uv*100,2),'%') as `美购首页-点击加车率`
,concat(round(T3.wel_home_buy_uv/T2.welfare_home_uv*100,2),'%') as `美购首页-点击立即支付率`
,concat(round(T3.wel_home_msg_uv/T2.welfare_home_uv*100,2),'%') as `美购首页-点击私信咨询率`
,T1.diary_detail_uv as `日记本详情页uv`
,T2.diary_detail_uv as `日记本详情页-转化uv`
,T3.diary_add_uv as `日记本详情页-转化点击加车uv`
,T3.diary_buy_uv as `日记本详情页-转化点击立即支付uv`
,T3.diary_msg_uv as `日记本详情页-转化点击私信咨询uv`
,concat(round(T2.diary_detail_uv/T1.diary_detail_uv*100,2),'%') as `日记本详情页-转化uv率`
,concat(round(T2.diary_detail_uv/T1.wel_uv*100,2),'%') as `日记本详情页-转化美购uv占比`
,concat(round(T3.diary_add_uv/T2.diary_detail_uv*100,2),'%') as `日记本详情页-点击加车率`
,concat(round(T3.diary_buy_uv/T2.diary_detail_uv*100,2),'%') as `日记本详情页-点击立即支付率`
,concat(round(T3.diary_msg_uv/T2.diary_detail_uv*100,2),'%') as `日记本详情页-点击私信咨询率`
,T1.sign_uv as `签到页uv`
,T2.sign_uv as `签到页-转化uv`
,T3.sign_add_uv as `签到页-转化点击加车uv`
,T3.sign_buy_uv as `签到页-转化点击立即支付uv`
,T3.sign_msg_uv as `签到页-转化点击私信咨询uv`
,concat(round(T2.sign_uv/T1.sign_uv*100,2),'%') as `签到页-转化uv率`
,concat(round(T2.sign_uv/T1.wel_uv*100,2),'%') as `签到页-转化美购uv占比`
,concat(round(T3.sign_add_uv/T2.sign_uv*100,2),'%') as `签到页-点击加车率`
,concat(round(T3.sign_buy_uv/T2.sign_uv*100,2),'%') as `签到页-点击立即支付率`
,concat(round(T3.sign_msg_uv/T2.sign_uv*100,2),'%') as `签到页-点击私信咨询率`
,T1.ai_report_uv as `AI结果页uv`
,T2.ai_report_uv as `AI结果页-转化uv`
,T3.ai_add_uv as `AI结果页-转化点击加车uv`
,T3.ai_buy_uv as `AI结果页-转化点击立即支付uv`
,T3.ai_msg_uv as `AI结果页-转化点击私信咨询uv`
,concat(round(T2.ai_report_uv/T1.ai_report_uv*100,2),'%') as `AI结果页-转化uv率`
,concat(round(T2.ai_report_uv/T1.wel_uv*100,2),'%') as `AI结果页-转化美购uv占比`
,concat(round(T3.ai_add_uv/T2.ai_report_uv*100,2),'%') as `AI结果页-点击加车率`
,concat(round(T3.ai_buy_uv/T2.ai_report_uv*100,2),'%') as `AI结果页-点击立即支付率`
,concat(round(T3.ai_msg_uv/T2.ai_report_uv*100,2),'%') as `AI结果页-点击私信咨询率`
,T1.zone_uv as `内容聚合页uv`
,T2.zone_uv as `内容聚合页-转化uv`
,T3.zone_add_uv as `内容聚合页-转化点击加车uv`
,T3.zone_buy_uv as `内容聚合页-转化点击立即支付uv`
,T3.zone_msg_uv as `内容聚合页-转化点击私信咨询uv`
,concat(round(T2.zone_uv/T1.zone_uv*100,2),'%') as `内容聚合页-转化uv率`
,concat(round(T2.zone_uv/T1.wel_uv*100,2),'%') as `内容聚合页-转化美购uv占比`
,concat(round(T3.zone_add_uv/T2.zone_uv*100,2),'%') as `内容聚合页-点击加车率`
,concat(round(T3.zone_buy_uv/T2.zone_uv*100,2),'%') as `内容聚合页-点击立即支付率`
,concat(round(T3.zone_msg_uv/T2.zone_uv*100,2),'%') as `内容聚合页-点击私信咨询率`
FROM
(
SELECT t1.partition_date
,t1.device_os_type
,t1.active_type
,t2.channel
,count(distinct case when page_name = 'welfare_detail' then t1.cl_id end) as wel_uv
,count(distinct case when page_name = 'search_result_more' then t1.cl_id end) as search_result_more_uv
,count(distinct case when page_name = 'search_result_welfare' then t1.cl_id end) as search_result_welfare_uv
,count(distinct case when page_name = 'organization_detail' then t1.cl_id end) as organization_detail_uv
,count(distinct case when page_name = 'expert_detail' then t1.cl_id end) as expert_detail_uv
,count(distinct case when page_name = 'category' then t1.cl_id end) as category_uv
,count(distinct case when page_name = 'welfare_list' then t1.cl_id end) as welfare_list_uv
,count(distinct case when page_name = 'welfare_home' then t1.cl_id end) as welfare_home_uv
,count(distinct case when page_name = 'conversation_detail' then t1.cl_id end) as conversation_detail_uv
,count(distinct case when page_name = 'my_cart' then t1.cl_id end) as my_cart_uv
,count(distinct case when page_name = 'diary_detail' then t1.cl_id end) as diary_detail_uv
,count(distinct case when page_name = 'order_detail' then t1.cl_id end) as order_detail_uv
,count(distinct case when page_name ='new_sign' then t1.cl_id end) as sign_uv
,count(distinct case when page_name in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion') then t1.cl_id end) as special_uv --专题和大促
,count(distinct case when page_name = 'zone_v3' then t1.cl_id end) as zone_uv
,count(distinct case when page_name in ('report_result','face_detect_result') then t1.cl_id end) as ai_report_uv --待之后增加模拟整形页面
FROM
(
SELECT t1.partition_date,t1.page_name,t1.cl_id,mas.device_os_type,mas.active_type,mas.channel
FROM
(
SELECT partition_date,page_name,cl_id
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='page_view'
)t1
JOIN
(
SELECT
partition_date
,m.device_id, device_os_type
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
)mas
ON t1.cl_id=mas.device_id
AND t1.partition_date=mas.partition_date
LEFT JOIN
(
SELECT cl_id
FROM online.ml_hospital_spam_pv_day
WHERE partition_date>='20180402' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
UNION ALL
SELECT cl_id
FROM online.ml_hospital_spam_pv_month
WHERE partition_date>='20171101' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
)spam_pv
on t1.cl_id=spam_pv.cl_id
WHERE spam_pv.cl_id IS NULL
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_os_type,t1.active_type,t2.channel
)T1
LEFT JOIN
(--不同referrer下的美购详情页uv/uv
(--能够走向美购详情页的各页面uv/uv
SELECT t1.partition_date
,t1.device_type
,t1.active_type
,t2.channel
,count(case when page_name = 'welfare_detail' then t1.cl_id end) as wel_uv
,count(case when page_name = 'search_result_more' then t1.cl_id end) as search_result_more_uv
,count(case when page_name = 'search_result_welfare' then t1.cl_id end) as search_result_welfare_uv
,count(case when page_name = 'organization_detail' then t1.cl_id end) as organization_detail_uv
,count(case when page_name = 'expert_detail' then t1.cl_id end) as expert_detail_uv
,count(case when page_name = 'category' then t1.cl_id end) as category_uv
,count(case when page_name = 'welfare_list' then t1.cl_id end) as welfare_list_uv
,count(case when page_name = 'welfare_home' then t1.cl_id end) as welfare_home_uv
,count(case when page_name = 'conversation_detail' then t1.cl_id end) as conversation_detail_uv
,count(case when page_name = 'my_cart' then t1.cl_id end) as my_cart_uv
,count(case when page_name = 'diary_detail' then t1.cl_id end) as diary_detail_uv
,count(case when page_name = 'order_detail' then t1.cl_id end) as order_detail_uv
,count(case when page_name ='new_sign' then t1.cl_id end) as sign_uv
,count(case when page_name in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion','custom_special') then t1.cl_id end) as special_uv --专题和大促
,count(case when page_name = 'zone_v3' then t1.cl_id end) as zone_uv
,count(case when page_name in ('report_result','face_detect_result') then t1.cl_id end) as ai_report_uv --待之后增加模拟整形页面
FROM
(
SELECT t1.partition_date,t1.page_name,t1.cl_id,mas.device_type,mas.active_type,mas.channel
FROM
(
SELECT partition_date,page_name,cl_id
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >=regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='page_view'
)t1
JOIN
(
SELECT partition_date,device_os_type as device_type,m.device_id
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL
or first_channel_source_type in ('promotion_aisi','promotion_koomobi_km00','promotion_koomobi_km01')
or first_channel_source_type like '%longyuzhixing%' or first_channel_source_type like '%jingmeng%'
or first_channel_source_type like '%mailuo%' THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
)mas
ON t1.cl_id=mas.device_id
AND t1.partition_date=mas.partition_date
LEFT JOIN
( -- 去掉疑似机构刷量的pV和UV
SELECT cl_id
FROM ml_hospital_spam_pv_day
WHERE partition_date>='20180402' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
UNION ALL
SELECT cl_id
FROM ml_hospital_spam_pv_month
WHERE partition_date>='20171101' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
)spam_pv
on t1.cl_id=spam_pv.cl_id
WHERE spam_pv.cl_id IS NULL
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_type,t1.active_type,t2.channel
)T1
LEFT JOIN
(--不同referrer下的美购详情页uv/uv
SELECT t1.partition_date
,t1.device_os_type
,t1.device_type
,t1.active_type
,t2.channel
,count(distinct case when referrer = 'welfare_detail' then t1.cl_id end) as wel_uv
,count(distinct case when referrer = 'search_result_more' then t1.cl_id end) as search_result_more_uv
,count(distinct case when referrer = 'search_result_welfare' then t1.cl_id end) as search_result_welfare_uv
,count(distinct case when referrer = 'organization_detail' then t1.cl_id end) as organization_detail_uv
,count(distinct case when referrer = 'expert_detail' then t1.cl_id end) as expert_detail_uv
,count(distinct case when referrer = 'category' then t1.cl_id end) as category_uv
,count(distinct case when referrer = 'welfare_list' then t1.cl_id end) as welfare_list_uv
,count(distinct case when referrer = 'welfare_home' then t1.cl_id end) as welfare_home_uv
,count(distinct case when referrer = 'conversation_detail' then t1.cl_id end) as conversation_detail_uv
,count(distinct case when referrer = 'my_cart' then t1.cl_id end) as my_cart_uv
,count(distinct case when referrer = 'diary_detail' then t1.cl_id end) as diary_detail_uv
,count(distinct case when referrer = 'order_detail' then t1.cl_id end) as order_detail_uv
,count(distinct case when referrer ='new_sign' then t1.cl_id end) as sign_uv
,count(distinct case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion') then t1.cl_id end) as special_uv --专题和大促
,count(distinct case when referrer = 'zone_v3' then t1.cl_id end) as zone_uv
,count(distinct case when referrer in ('report_result','face_detect_result') then t1.cl_id end) as ai_report_uv --待之后增加模拟整形页面
,count(case when referrer = 'welfare_detail' then t1.cl_id end) as wel_uv
,count(case when referrer = 'search_result_more' then t1.cl_id end) as search_result_more_uv
,count(case when referrer = 'search_result_welfare' then t1.cl_id end) as search_result_welfare_uv
,count(case when referrer = 'organization_detail' then t1.cl_id end) as organization_detail_uv
,count(case when referrer = 'expert_detail' then t1.cl_id end) as expert_detail_uv
,count(case when referrer = 'category' then t1.cl_id end) as category_uv
,count(case when referrer = 'welfare_list' then t1.cl_id end) as welfare_list_uv
,count(case when referrer = 'welfare_home' then t1.cl_id end) as welfare_home_uv
,count(case when referrer = 'conversation_detail' then t1.cl_id end) as conversation_detail_uv
,count(case when referrer = 'my_cart' then t1.cl_id end) as my_cart_uv
,count(case when referrer = 'diary_detail' then t1.cl_id end) as diary_detail_uv
,count(case when referrer = 'order_detail' then t1.cl_id end) as order_detail_uv
,count(case when referrer ='new_sign' then t1.cl_id end) as sign_uv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion','custom_special') then t1.cl_id end) as special_uv --专题和大促
,count(case when referrer = 'zone_v3' then t1.cl_id end) as zone_uv
,count(case when referrer in ('report_result','face_detect_result') then t1.cl_id end) as ai_report_uv --待之后增加模拟整形页面
FROM
(
SELECT t1.partition_date,t1.referrer,t1.cl_id,mas.device_os_type,mas.active_type,mas.channel
SELECT t1.partition_date,t1.referrer,t1.cl_id,mas.device_type,mas.active_type,mas.channel
FROM
(
SELECT partition_date,referrer,cl_id
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='page_view'
)t1
JOIN
(
SELECT
partition_date
,m.device_id, device_os_type
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
SELECT partition_date,device_os_type as device_type,m.device_id
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL
or first_channel_source_type in ('promotion_aisi','promotion_koomobi_km00','promotion_koomobi_km01')
or first_channel_source_type like '%longyuzhixing%' or first_channel_source_type like '%jingmeng%'
or first_channel_source_type like '%mailuo%' THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
)mas
ON t1.cl_id=mas.device_id
AND t1.partition_date=mas.partition_date
LEFT JOIN
( -- 去掉疑似机构刷量的PV和UV
( -- 去掉疑似机构刷量的pV和UV
SELECT cl_id
FROM online.ml_hospital_spam_pv_day
FROM ml_hospital_spam_pv_day
WHERE partition_date>='20180402' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
UNION ALL
SELECT cl_id
FROM online.ml_hospital_spam_pv_month
FROM ml_hospital_spam_pv_month
WHERE partition_date>='20171101' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
)spam_pv
......@@ -340,75 +344,75 @@ FROM
WHERE spam_pv.cl_id IS NULL
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_os_type,t1.active_type,t2.channel
GROUP BY t1.partition_date,t1.device_type,t1.active_type,t2.channel
)T2
ON T1.partition_date=T2.partition_date
and T1.device_os_type=T2.device_os_type
AND T1.active_type=T2.active_type
AND T1.channel=T2.channel
LEFT JOIN
(--点击加车/支付/私信的不同来源
ON T1.partition_date=T2.partition_date
and T1.device_type=T2.device_type
AND T1.active_type=T2.active_type
AND T1.channel=T2.channel
LEFT JOIN
(--点击加车/支付/私信的不同来源
SELECT t1.partition_date
,t1.device_os_type
,t1.device_type
,t1.active_type
,t2.channel
,count(distinct case when referrer = 'welfare_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as wel_add_uv
,count(distinct case when referrer = 'welfare_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as wel_buy_uv
,count(distinct case when referrer = 'welfare_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as wel_msg_uv
,count(distinct case when referrer = 'search_result_more' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as result_more_add_uv
,count(distinct case when referrer = 'search_result_more' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as result_more_buy_uv
,count(distinct case when referrer = 'search_result_more' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as result_more_msg_uv
,count(distinct case when referrer = 'search_result_welfare' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as result_wel_add_uv
,count(distinct case when referrer = 'search_result_welfare' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as result_wel_buy_uv
,count(distinct case when referrer = 'search_result_welfare' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as result_wel_msg_uv
,count(distinct case when referrer = 'organization_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as org_add_uv
,count(distinct case when referrer = 'organization_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as org_buy_uv
,count(distinct case when referrer = 'organization_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as org_msg_uv
,count(distinct case when referrer = 'expert_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as exp_add_uv
,count(distinct case when referrer = 'expert_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as exp_buy_uv
,count(distinct case when referrer = 'expert_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as exp_msg_uv
,count(distinct case when referrer = 'category' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as category_add_uv
,count(distinct case when referrer = 'category' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as category_buy_uv
,count(distinct case when referrer = 'category' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as category_msg_uv
,count(distinct case when referrer = 'welfare_list' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as wel_list_add_uv
,count(distinct case when referrer = 'welfare_list' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as wel_list_buy_uv
,count(distinct case when referrer = 'welfare_list' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as wel_list_msg_uv
,count(distinct case when referrer = 'welfare_home' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as wel_home_add_uv
,count(distinct case when referrer = 'welfare_home' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as wel_home_buy_uv
,count(distinct case when referrer = 'welfare_home' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as wel_home_msg_uv
,count(distinct case when referrer = 'conversation_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as conv_add_uv
,count(distinct case when referrer = 'conversation_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as conv_buy_uv
,count(distinct case when referrer = 'conversation_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as conv_msg_uv
,count(distinct case when referrer = 'my_cart' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as cart_add_uv
,count(distinct case when referrer = 'my_cart' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as cart_buy_uv
,count(distinct case when referrer = 'my_cart' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as cart_msg_uv
,count(distinct case when referrer = 'diary_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as diary_add_uv
,count(distinct case when referrer = 'diary_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as diary_buy_uv
,count(distinct case when referrer = 'diary_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as diary_msg_uv
,count(distinct case when referrer = 'order_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as order_add_uv
,count(distinct case when referrer = 'order_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as order_buy_uv
,count(distinct case when referrer = 'order_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as order_msg_uv
,count(distinct case when referrer = 'new_sign' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as sign_add_uv
,count(distinct case when referrer = 'new_sign' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as sign_buy_uv
,count(distinct case when referrer = 'new_sign' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as sign_msg_uv
,count(distinct case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion') and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as special_add_uv
,count(distinct case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion') and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as special_buy_uv
,count(distinct case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion') and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as special_msg_uv
,count(distinct case when referrer = 'zone_v3' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as zone_add_uv
,count(distinct case when referrer = 'zone_v3' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as zone_buy_uv
,count(distinct case when referrer = 'zone_v3' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as zone_msg_uv
,count(distinct case when referrer in ('report_result','face_detect_result') and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as ai_add_uv
,count(distinct case when referrer in ('report_result','face_detect_result') and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as ai_buy_uv
,count(distinct case when referrer in ('report_result','face_detect_result') and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as ai_msg_uv
,count(case when referrer = 'welfare_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as wel_add_uv
,count(case when referrer = 'welfare_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as wel_buy_uv
,count(case when referrer = 'welfare_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as wel_msg_uv
,count(case when referrer = 'search_result_more' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as result_more_add_uv
,count(case when referrer = 'search_result_more' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as result_more_buy_uv
,count(case when referrer = 'search_result_more' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as result_more_msg_uv
,count(case when referrer = 'search_result_welfare' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as result_wel_add_uv
,count(case when referrer = 'search_result_welfare' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as result_wel_buy_uv
,count(case when referrer = 'search_result_welfare' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as result_wel_msg_uv
,count(case when referrer = 'organization_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as org_add_uv
,count(case when referrer = 'organization_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as org_buy_uv
,count(case when referrer = 'organization_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as org_msg_uv
,count(case when referrer = 'expert_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as exp_add_uv
,count(case when referrer = 'expert_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as exp_buy_uv
,count(case when referrer = 'expert_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as exp_msg_uv
,count(case when referrer = 'category' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as category_add_uv
,count(case when referrer = 'category' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as category_buy_uv
,count(case when referrer = 'category' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as category_msg_uv
,count(case when referrer = 'welfare_list' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as wel_list_add_uv
,count(case when referrer = 'welfare_list' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as wel_list_buy_uv
,count(case when referrer = 'welfare_list' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as wel_list_msg_uv
,count(case when referrer = 'welfare_home' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as wel_home_add_uv
,count(case when referrer = 'welfare_home' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as wel_home_buy_uv
,count(case when referrer = 'welfare_home' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as wel_home_msg_uv
,count(case when referrer = 'conversation_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as conv_add_uv
,count(case when referrer = 'conversation_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as conv_buy_uv
,count(case when referrer = 'conversation_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as conv_msg_uv
,count(case when referrer = 'my_cart' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as cart_add_uv
,count(case when referrer = 'my_cart' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as cart_buy_uv
,count(case when referrer = 'my_cart' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as cart_msg_uv
,count(case when referrer = 'diary_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as diary_add_uv
,count(case when referrer = 'diary_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as diary_buy_uv
,count(case when referrer = 'diary_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as diary_msg_uv
,count(case when referrer = 'order_detail' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as order_add_uv
,count(case when referrer = 'order_detail' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as order_buy_uv
,count(case when referrer = 'order_detail' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as order_msg_uv
,count(case when referrer = 'new_sign' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as sign_add_uv
,count(case when referrer = 'new_sign' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as sign_buy_uv
,count(case when referrer = 'new_sign' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as sign_msg_uv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion','custom_special') and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as special_add_uv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion','custom_special') and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as special_buy_uv
,count(case when referrer in ('special_polymer','newt_welfare_special','welfare_special','activity_promotion_seckill','activity_promotion','custom_special') and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as special_msg_uv
,count(case when referrer = 'zone_v3' and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as zone_add_uv
,count(case when referrer = 'zone_v3' and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as zone_buy_uv
,count(case when referrer = 'zone_v3' and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as zone_msg_uv
,count(case when referrer in ('report_result','face_detect_result') and action = 'welfare_multiattribute_click_add' then t1.cl_id end) as ai_add_uv
,count(case when referrer in ('report_result','face_detect_result') and action = 'welfare_multiattribute_click_buy' then t1.cl_id end) as ai_buy_uv
,count(case when referrer in ('report_result','face_detect_result') and action in ('welfare_detail_click_message','on_click_button') then t1.cl_id end) as ai_msg_uv
FROM
(
SELECT t1.partition_date,t1.referrer,t1.action,t1.cl_id,mas.device_os_type,mas.active_type,mas.channel
SELECT t1.partition_date,t1.referrer,t1.action,t1.cl_id,mas.device_type,mas.active_type,mas.channel
FROM
( --点击加车/支付
SELECT partition_date,referrer,action,cl_id
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >=regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >=regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action in ('welfare_multiattribute_click_add','welfare_multiattribute_click_buy')
......@@ -417,57 +421,80 @@ FROM
--点击私信按钮
SELECT partition_date,referrer,action,cl_id
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >=regexp_replace(DATE_SUB(current_date,90) ,'-','')
WHERE partition_date >=regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
--AND page_name = 'welfare_detail'
AND action='welfare_detail_click_message'
UNION ALL
--点击私信区域(目前referrer缺失,故通过拆解referrer_link的方式获得)
SELECT partition_date,referrer,action,cl_id
FROM
(
SELECT partition_date,cl_id,action,t2.referrer as referrer
,row_number () over (PARTITION BY t1.referrer_link,t1.cl_id ORDER BY t2.link_id desc) as rank
from
( SELECT partition_date,params['referrer_link'] as referrer_link,cl_id,action
,json_split(params['referrer_link'],'string') as a
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND page_name = 'welfare_detail'
AND action='on_click_button'
AND params['button_name'] in ('question_tag','appointment')
)t1
lateral view posexplode(a) t2 as link_id,referrer
)t3
where rank=1
)t1
JOIN
(
SELECT
partition_date
,m.device_id, device_os_type
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date>=regexp_replace(DATE_SUB(current_date,90) ,'-','')
AND partition_date<regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
SELECT partition_date,device_os_type as device_type,m.device_id
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,array(CASE WHEN first_channel_source_type like '%xinyouxingkong%' or a.device_id is not NULL
or first_channel_source_type in ('promotion_aisi','promotion_koomobi_km00','promotion_koomobi_km01')
or first_channel_source_type like '%longyuzhixing%' or first_channel_source_type like '%jingmeng%'
or first_channel_source_type like '%mailuo%' THEN '可疑'
WHEN (partition_date>='20190601' and tmp.col2 = 'AI')
or (partition_date < '20200301' AND partition_date>='20190601' and first_channel_source_type like 'promotion_toutiao_jy%')
or (partition_date>='20200601' and ((first_channel_source_type like 'promotion_toutiao_jy%') or (first_channel_source_type like 'dyand%') or (first_channel_source_type like 'douyin%')))
THEN 'AI' ELSE '其他' END , '合计') as channel
FROM online.ml_device_day_active_status m
LEFT JOIN
(SELECT col1,col2 --col1:子渠道,col2:是否属于AI,col3:标识
FROM pm.tl_pm_ydl
WHERE col3='0204_danlei_channel')tmp
on first_channel_source_type=tmp.col1
LEFT JOIN
(SELECT DISTINCT device_id
FROM al.al_pm_ct_dv_deviceappversionrollbackfrom20200101_d
WHERE partition_day = regexp_replace(DATE_SUB(current_date,2) ,'-',''))a
ON m.device_id = a.device_id
where partition_date >= regexp_replace((current_date - interval '90' day),'-','')
AND partition_date < regexp_replace((current_date),'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei','','unknown')
AND first_channel_source_type not like 'promotion\_jf\_%'
)mas
ON t1.cl_id=mas.device_id
AND t1.partition_date=mas.partition_date
LEFT JOIN
( -- 去掉疑似机构刷量的PV和UV
SELECT cl_id
FROM online.ml_hospital_spam_pv_day
FROM ml_hospital_spam_pv_day
WHERE partition_date>='20180402' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
UNION ALL
SELECT cl_id
FROM online.ml_hospital_spam_pv_month
FROM ml_hospital_spam_pv_month
WHERE partition_date>='20171101' AND partition_date<regexp_replace((current_date),'-','')
AND pv_ratio>=0.95
)spam_pv
......@@ -475,10 +502,11 @@ FROM
WHERE spam_pv.cl_id IS NULL
)t1
LATERAL VIEW explode(t1.channel) t2 AS channel
GROUP BY t1.partition_date,t1.device_os_type,t1.active_type,t2.channel
GROUP BY t1.partition_date,t1.device_type,t1.active_type,t2.channel
)T3
ON T1.partition_date=T3.partition_date
and T1.device_os_type=T3.device_os_type
AND T1.active_type=T3.active_type
AND T1.channel=T3.channel
ORDER BY `日期` desc,`设备类型`,`活跃类型`,`渠道`
\ No newline at end of file
ON T1.partition_date=T3.partition_date
and T1.device_type=T3.device_type
AND T1.active_type=T3.active_type
AND T1.channel=T3.channel
ORDER BY `日期` desc,`设备类型`,`活跃类型`,`渠道`
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment