Commit 402da4bb authored by yindanlei's avatar yindanlei

add fangan_day report codes

parent 98910277
......@@ -22,7 +22,9 @@ CREATE TABLE IF NOT EXISTS pm.tl_pm_fangan_d
new_DAU BIGINT comment '{"chs_name":"新增DAU","description":"","etl":"","value":"","remark":""}',
old_DAU BIGINT comment '{"chs_name":"老活DAU","description":"","etl":"","value":"","remark":""}',
quanzhong_DAU BIGINT comment '{"chs_name":"权重日活","description":"","etl":"","value":"","remark":""}',
liucun DOUBLE comment '{"chs_name":"次日留存率(%)","description":"","etl":"","value":"","remark":""}',
liucun_1 DOUBLE comment '{"chs_name":"次日留存率(%)","description":"","etl":"","value":"","remark":""}',
liucun_3 DOUBLE comment '{"chs_name":"3日留存率(%)","description":"","etl":"","value":"","remark":""}',
liucun_7 DOUBLE comment '{"chs_name":"7日留存率(%)","description":"","etl":"","value":"","remark":""}',
wel_pv BIGINT comment '{"chs_name":"商详PV","description":"","etl":"","value":"","remark":""}',
wel_uv BIGINT comment '{"chs_name":"商详UV","description":"","etl":"","value":"","remark":""}',
pay_num BIGINT comment '{"chs_name":"支付订单数","description":"","etl":"","value":"","remark":""}',
......
......@@ -26,7 +26,9 @@ SELECT t1.partition_date as day_id
+count(DISTINCT CASE WHEN device_type = '老活' AND device_os_type = 'ios' AND channel_type = '医美' THEN t1.device_id END)*1.00
+count(DISTINCT CASE WHEN device_type = '新增' AND device_os_type = 'ios' AND channel_type = 'AI' THEN t1.device_id END)*0.21
+count(DISTINCT CASE WHEN device_type = '新增' AND device_os_type = 'ios' AND channel_type = '医美' THEN t1.device_id END)*0.21,0) as quanzhong_DAU
,round(sum(t1.rent_num)/count(DISTINCT t1.device_id)*100,2) as liucun
,round(sum(t1.rent1_num)/count(DISTINCT t1.device_id)*100,2) as liucun_1
,round(sum(t1.rent3_num)/count(DISTINCT t1.device_id)*100,2) as liucun_3
,round(sum(t1.rent7_num)/count(DISTINCT t1.device_id)*100,2) as liucun_7
,sum(wel_pv) as wel_pv
,count(DISTINCT CASE WHEN wel_pv is not NULL and wel_pv <> 0 THEN t3.cl_id END) as wel_uv
,sum(pay_num) as pay_num
......@@ -35,7 +37,10 @@ SELECT t1.partition_date as day_id
,count(DISTINCT t6.device_id) as true_valid_dev_num
,sum(t6.clue_num) as true_valid_pv
FROM
( SELECT t1.partition_date,t1.device_id,device_type,device_os_type,channel_type,grey_type,count(DISTINCT CASE WHEN date_add(t1.partition_date,1) = t.partition_date THEN t.device_id END) as rent_num
( SELECT t1.partition_date,t1.device_id,device_type,device_os_type,channel_type,grey_type
,count(DISTINCT CASE WHEN date_add(t1.partition_date,1) = t.partition_date THEN t.device_id END) as rent1_num
,count(DISTINCT CASE WHEN date_add(t1.partition_date,3) = t.partition_date THEN t.device_id END) as rent3_num
,count(DISTINCT CASE WHEN date_add(t1.partition_date,7) = t.partition_date THEN t.device_id END) as rent7_num
FROM
(---dau数据
SELECT concat_ws('-',substr(partition_date,1,4),substr(partition_date,5,2),substr(partition_date,7,2)) as partition_date,device_id,device_os_type
......
......@@ -7,7 +7,9 @@ SELECT
,new_DAU AS `新增DAU`
,old_DAU AS `老活DAU`
,quanzhong_DAU AS `权重日活`
,liucun AS `次日留存率(%)`
,liucun_1 AS `次日留存率(%)`
,liucun_3 AS `3日留存率(%)`
,liucun_7 AS `7日留存率(%)`
,wel_pv AS `商详PV`
,wel_uv AS `商详UV`
,pay_num AS `支付订单数`
......
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