Commit 656f5259 authored by 魏艺敏's avatar 魏艺敏

push codes

parent 010cbfec
...@@ -20,6 +20,8 @@ SELECT T1.partition_date as day_id ...@@ -20,6 +20,8 @@ SELECT T1.partition_date as day_id
,T1.grey_type ,T1.grey_type
,dau ,dau
,user_num ,user_num
,total_valid_dev
,total_valid_num
,msg_dev ,msg_dev
,msg_num ,msg_num
,valid_msg_dev ,valid_msg_dev
...@@ -87,6 +89,9 @@ FROM ...@@ -87,6 +89,9 @@ FROM
,grey_type ,grey_type
,count(distinct mas.device_id) as dau ,count(distinct mas.device_id) as dau
,count(distinct a.user_id) as user_num ,count(distinct a.user_id) as user_num
,nvl(count(distinct case when t13_v.total_valid_num>0 then t13_v.user_id end),0) total_valid_dev
,nvl(sum(t13_v.total_valid_num),0) total_valid_num
,nvl(count(distinct case when t1.msg_num>0 then t1.user_id end),0) msg_dev ,nvl(count(distinct case when t1.msg_num>0 then t1.user_id end),0) msg_dev
,nvl(sum(t1.msg_num),0) msg_num ,nvl(sum(t1.msg_num),0) msg_num
,nvl(count(distinct case when t1_v.valid_msg_num>0 then t1_v.user_id end),0) valid_msg_dev ,nvl(count(distinct case when t1_v.valid_msg_num>0 then t1_v.user_id end),0) valid_msg_dev
...@@ -1089,6 +1094,90 @@ FROM ...@@ -1089,6 +1094,90 @@ FROM
GROUP BY user_id,partition_date GROUP BY user_id,partition_date
)t12_v )t12_v
ON a.partition_date = t12_v.partition_date and a.user_id=t12_v.user_id ON a.partition_date = t12_v.partition_date and a.user_id=t12_v.user_id
left join
(
SELECT partition_date,user_id,sum(valid_num) as total_valid_num
from
( ---拨打有效电话线索
SELECT partition_date,user_id,count(1) as valid_num
FROM
(
SELECT user_id,merchant_id,regexp_replace(SUBSTR(a.partition_date,1,6),'-','') AS CALL_MONTH,
MIN(partition_date) as partition_date,
1 as call_num
FROM
(
SELECT sub_id,REGEXP_REPLACE(SUBSTR(call_time,0,10), '-', '') as partition_date
FROM tl.tl_gm_sl_ali_virtual_phone_call_detail --通话记录表,call_type呼叫类型
WHERE partition_day=regexp_replace(date_sub(current_date,1),'-','')
AND REGEXP_REPLACE(SUBSTR(call_time,0,10), '-', '')>=REGEXP_REPLACE(trunc(date_sub(current_date(),1),'MM'),'-','')
AND REGEXP_REPLACE(SUBSTR(call_time,0,10), '-', '')<=regexp_replace(date_sub(current_date(),1),'-','')
and start_time>call_time
and start_time<release_time
)a
LEFT JOIN
(
SELECT id,sub_id
FROM tl.tl_gm_sl_ali_virtual_phone_binding --阿里记录表
WHERE partition_day=regexp_replace(date_sub(current_date,1),'-','')
)b
ON a.sub_id = b.sub_id
LEFT JOIN
(
SELECT id,platform_binding_id
FROM tl.tl_gm_sl_virtual_phone_binding
WHERE partition_day=regexp_replace(date_sub(current_date,1),'-','')
)c
ON b.id = c.platform_binding_id
LEFT JOIN
(
SELECT phone_binding_id,lead_task_id
FROM tl.tl_gm_sl_lead_task_phone_binding
WHERE partition_day=regexp_replace(date_sub(current_date,1),'-','')
)d
ON c.id = d.phone_binding_id
JOIN
(
SELECT id,user_id,merchant_id
FROM tl.tl_gm_sl_lead_task --线索任务表(用户点击授权后记入该表)
WHERE partition_day=regexp_replace(date_sub(current_date,1),'-','')
AND source='2' --用户行为电话授权
)e
ON d.lead_task_id = e.id
GROUP BY user_id,merchant_id,regexp_replace(SUBSTR(a.partition_date,1,6),'-','')
)t1
join
(
SELECT distinct merchant_id
FROM
(
SELECT merchant_id,merchant_level
,row_number() over(partition by merchant_id order by data_month desc) as rn
FROM online.al_business_merchant_grade_day_repo
where partition_date=regexp_replace(date_sub(current_date,1),'-','')
)a
where rn=1 and merchant_level>=3
)b
on t1.merchant_id=b.merchant_id
GROUP BY user_id,partition_date
union all
SELECT msg.partition_date,user_id,count(msg.merchant_id) as valid_num
FROM
(
SELECT user_id,merchant_id,SUBSTR(partition_day,1,6) AS MONTH,min(partition_day) as partition_date
FROM ml.ml_c_et_msg_conversation_dimen_inc_d --新仓库私信表
WHERE partition_day >=REGEXP_REPLACE(trunc(date_sub(current_date(),1),'MM'),'-','')
AND partition_day <= regexp_replace(date_sub(current_date,1),'-','')
and is_valid='true'
GROUP BY user_id,merchant_id,SUBSTR(partition_day,1,6)
)msg
GROUP BY msg.partition_date,user_id
)a
group by partition_date,user_id
)t13_v
ON a.partition_date = t13_v.partition_date and a.user_id=t13_v.user_id
group by mas.partition_date,device_os_type,active_type,grey_type group by mas.partition_date,device_os_type,active_type,grey_type
)T1 )T1
LEFT JOIN LEFT JOIN
......
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