Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bi-report
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data
bi-report
Commits
a371d573
Commit
a371d573
authored
Aug 21, 2020
by
魏艺敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push codes
parent
c530a989
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1224 additions
and
551 deletions
+1224
-551
clue_daily.sql
pm/clue_daily/etl/clue_daily.sql
+707
-135
create_clue_daily.sql
pm/clue_daily/etl/create_clue_daily.sql
+38
-23
clue_daily.sql
pm/clue_daily/report/clue_daily.sql
+38
-22
meigou_detail_page_dispense_pv.sql
...gou_detail_page/report/meigou_detail_page_dispense_pv.sql
+31
-22
meigou_detail_page_dispense_uv.sql
...gou_detail_page/report/meigou_detail_page_dispense_uv.sql
+186
-177
meigou_detail_page_source_pv.sql
...eigou_detail_page/report/meigou_detail_page_source_pv.sql
+112
-86
meigou_detail_page_source_uv.sql
...eigou_detail_page/report/meigou_detail_page_source_uv.sql
+112
-86
No files found.
pm/clue_daily/etl/clue_daily.sql
View file @
a371d573
SET
mapreduce
.
job
.
queuename
=
data
;
SET
mapreduce
.
job
.
queuename
=
data
;
SET
mapreduce
.
map
.
memory
.
mb
=
8192
;
SET
mapreduce
.
map
.
java
.
opts
=-
Xmx8000m
;
SET
mapreduce
.
reduce
.
memory
.
mb
=
8192
;
SET
mapreduce
.
reduce
.
java
.
opts
=-
Xmx8000m
;
set
hive
.
auto
.
convert
.
join
=
true
;
SET
mapred
.
reduce
.
tasks
=
20
;
SET
role
admin
;
SET
role
admin
;
--线索日报
--线索日报
ADD
JAR
hdfs
:
///
user
/
hive
/
share
/
lib
/
udf
/
hive
-
udf
-
1
.
0
-
SNAPSHOT
.
jar
;
ADD
JAR
hdfs
:
///
user
/
hive
/
share
/
lib
/
udf
/
hive
-
udf
-
1
.
0
-
SNAPSHOT
.
jar
;
CREATE
TEMPORARY
FUNCTION
convup
AS
'com.gmei.hive.common.udf.UDFConvUpgrade'
;
CREATE
TEMPORARY
FUNCTION
convup
AS
'com.gmei.hive.common.udf.UDFConvUpgrade'
;
CREATE
TEMPORARY
FUNCTION
setencryption
AS
'com.gmei.hive.common.udf.UDFStringSetEncryption'
;
CREATE
TEMPORARY
FUNCTION
setencryption
AS
'com.gmei.hive.common.udf.UDFStringSetEncryption'
;
INSERT
OVERWRITE
TABLE
pm
.
tl_pm_userclue_d
PARTITION
(
PARTITION_DAY
=
${
partition_day
}
)
INSERT
OVERWRITE
TABLE
pm
.
tl_pm_userclue_d
PARTITION
(
PARTITION_DAY
=
${
partition_day
}
)
SELECT
T1
.
partition_date
as
day_id
SELECT
T1
.
partition_date
as
day_id
,
T1
.
device_os_type
,
T1
.
device_os_type
...
@@ -30,17 +24,25 @@ SELECT T1.partition_date as day_id
...
@@ -30,17 +24,25 @@ SELECT T1.partition_date as day_id
,
nvl
(
call_num
,
0
)
,
nvl
(
call_num
,
0
)
,
nvl
(
valid_call_dev
,
0
)
,
nvl
(
valid_call_dev
,
0
)
,
nvl
(
valid_call_num
,
0
)
,
nvl
(
valid_call_num
,
0
)
,
nvl
(
call_dev_d
,
0
)
,
nvl
(
call_num_d
,
0
)
,
nvl
(
valid_call_dev_d
,
0
)
,
nvl
(
valid_call_num_d
,
0
)
,
msg_dev_4
,
msg_dev_3
,
msg_num_4
,
msg_num_3
,
valid_msg_dev_4
,
valid_msg_dev_3
,
valid_msg_num_4
,
valid_msg_num_3
,
clue_dev_4
,
clue_dev_3
,
clue_num_4
,
clue_num_3
,
nvl
(
call_dev_4
,
0
)
,
nvl
(
call_dev_3
,
0
)
,
nvl
(
call_num_4
,
0
)
,
nvl
(
call_num_3
,
0
)
,
nvl
(
valid_call_dev_4
,
0
)
,
nvl
(
valid_call_dev_3
,
0
)
,
nvl
(
valid_call_num_4
,
0
)
,
nvl
(
valid_call_num_3
,
0
)
,
nvl
(
call_dev_3_d
,
0
)
,
nvl
(
call_num_3_d
,
0
)
,
nvl
(
valid_call_dev_3_d
,
0
)
,
nvl
(
valid_call_num_3_d
,
0
)
,
msg_dev_kyc
,
msg_dev_kyc
,
msg_num_kyc
,
msg_num_kyc
...
@@ -52,6 +54,10 @@ SELECT T1.partition_date as day_id
...
@@ -52,6 +54,10 @@ SELECT T1.partition_date as day_id
,
nvl
(
call_num_kyc
,
0
)
,
nvl
(
call_num_kyc
,
0
)
,
nvl
(
valid_call_dev_kyc
,
0
)
,
nvl
(
valid_call_dev_kyc
,
0
)
,
nvl
(
valid_call_num_kyc
,
0
)
,
nvl
(
valid_call_num_kyc
,
0
)
,
nvl
(
call_dev_kyc_d
,
0
)
,
nvl
(
call_num_kyc_d
,
0
)
,
nvl
(
valid_call_dev_kyc_d
,
0
)
,
nvl
(
valid_call_num_kyc_d
,
0
)
,
msg_dev_qa
,
msg_dev_qa
,
msg_num_qa
,
msg_num_qa
...
@@ -63,6 +69,10 @@ SELECT T1.partition_date as day_id
...
@@ -63,6 +69,10 @@ SELECT T1.partition_date as day_id
,
nvl
(
call_num_qa
,
0
)
,
nvl
(
call_num_qa
,
0
)
,
nvl
(
valid_call_dev_qa
,
0
)
,
nvl
(
valid_call_dev_qa
,
0
)
,
nvl
(
valid_call_num_qa
,
0
)
,
nvl
(
valid_call_num_qa
,
0
)
,
nvl
(
call_dev_qa_d
,
0
)
,
nvl
(
call_num_qa_d
,
0
)
,
nvl
(
valid_call_dev_qa_d
,
0
)
,
nvl
(
valid_call_num_qa_d
,
0
)
FROM
FROM
(
(
SELECT
mas
.
partition_date
as
partition_date
SELECT
mas
.
partition_date
as
partition_date
...
@@ -78,14 +88,12 @@ FROM
...
@@ -78,14 +88,12 @@ FROM
,
nvl
(
count
(
distinct
case
when
t2
.
clue_num
>
0
then
t2
.
user_id
end
),
0
)
as
clue_dev
,
nvl
(
count
(
distinct
case
when
t2
.
clue_num
>
0
then
t2
.
user_id
end
),
0
)
as
clue_dev
,
nvl
(
sum
(
t2
.
clue_num
),
0
)
as
clue_num
,
nvl
(
sum
(
t2
.
clue_num
),
0
)
as
clue_num
,
nvl
(
count
(
distinct
case
when
t10
.
msg_num
>
0
then
t10
.
user_id
end
),
0
)
msg_dev_3
,
nvl
(
count
(
distinct
case
when
t10
.
msg_num
>
0
then
t10
.
user_id
end
),
0
)
msg_dev_4
,
nvl
(
sum
(
t10
.
msg_num
),
0
)
msg_num_3
,
nvl
(
sum
(
t10
.
msg_num
),
0
)
msg_num_4
,
nvl
(
count
(
distinct
case
when
t10_v
.
valid_msg_num
>
0
then
t10_v
.
user_id
end
),
0
)
valid_msg_dev_3
,
nvl
(
count
(
distinct
case
when
t10_v
.
valid_msg_num
>
0
then
t10_v
.
user_id
end
),
0
)
valid_msg_dev_4
,
nvl
(
sum
(
t10_v
.
valid_msg_num
),
0
)
as
valid_msg_num_3
,
nvl
(
sum
(
t10_v
.
valid_msg_num
),
0
)
as
valid_msg_num_4
,
nvl
(
count
(
distinct
case
when
t11
.
clue_num
>
0
then
t11
.
user_id
end
),
0
)
as
clue_dev_3
,
nvl
(
count
(
distinct
case
when
t11
.
clue_num
>
0
then
t11
.
user_id
end
),
0
)
as
clue_dev_4
,
nvl
(
sum
(
t11
.
clue_num
),
0
)
as
clue_num_3
,
nvl
(
sum
(
t11
.
clue_num
),
0
)
as
clue_num_4
,
nvl
(
count
(
distinct
case
when
t4
.
msg_num
>
0
then
t4
.
user_id
end
),
0
)
msg_dev_kyc
,
nvl
(
count
(
distinct
case
when
t4
.
msg_num
>
0
then
t4
.
user_id
end
),
0
)
msg_dev_kyc
,
nvl
(
sum
(
t4
.
msg_num
),
0
)
msg_num_kyc
,
nvl
(
sum
(
t4
.
msg_num
),
0
)
msg_num_kyc
...
@@ -94,7 +102,6 @@ FROM
...
@@ -94,7 +102,6 @@ FROM
,
nvl
(
count
(
distinct
case
when
t5
.
clue_num
>
0
then
t5
.
user_id
end
),
0
)
as
clue_dev_kyc
,
nvl
(
count
(
distinct
case
when
t5
.
clue_num
>
0
then
t5
.
user_id
end
),
0
)
as
clue_dev_kyc
,
nvl
(
sum
(
t5
.
clue_num
),
0
)
as
clue_num_kyc
,
nvl
(
sum
(
t5
.
clue_num
),
0
)
as
clue_num_kyc
,
nvl
(
count
(
distinct
case
when
t7
.
msg_num
>
0
then
t7
.
user_id
end
),
0
)
msg_dev_qa
,
nvl
(
count
(
distinct
case
when
t7
.
msg_num
>
0
then
t7
.
user_id
end
),
0
)
msg_dev_qa
,
nvl
(
sum
(
t7
.
msg_num
),
0
)
msg_num_qa
,
nvl
(
sum
(
t7
.
msg_num
),
0
)
msg_num_qa
,
nvl
(
count
(
distinct
case
when
t7_v
.
valid_msg_num
>
0
then
t7_v
.
user_id
end
),
0
)
valid_msg_dev_qa
,
nvl
(
count
(
distinct
case
when
t7_v
.
valid_msg_num
>
0
then
t7_v
.
user_id
end
),
0
)
valid_msg_dev_qa
...
@@ -102,16 +109,36 @@ FROM
...
@@ -102,16 +109,36 @@ FROM
,
nvl
(
count
(
distinct
case
when
t8
.
clue_num
>
0
then
t8
.
user_id
end
),
0
)
as
clue_dev_qa
,
nvl
(
count
(
distinct
case
when
t8
.
clue_num
>
0
then
t8
.
user_id
end
),
0
)
as
clue_dev_qa
,
nvl
(
sum
(
t8
.
clue_num
),
0
)
as
clue_num_qa
,
nvl
(
sum
(
t8
.
clue_num
),
0
)
as
clue_num_qa
,
nvl
(
count
(
distinct
case
when
t3
.
call_num
>
0
then
t3
.
user_id
end
),
0
)
as
call_dev
,
nvl
(
sum
(
t3
.
call_num
),
0
)
as
call_num
,
nvl
(
count
(
distinct
case
when
t3_v
.
valid_call_num
>
0
then
t3_v
.
user_id
end
),
0
)
as
valid_call_dev
,
nvl
(
sum
(
t3_v
.
valid_call_num
),
0
)
as
valid_call_num
,
nvl
(
count
(
distinct
case
when
t12
.
call_num
>
0
then
t12
.
user_id
end
),
0
)
as
call_dev_3
,
nvl
(
sum
(
t12
.
call_num
),
0
)
as
call_num_3
,
nvl
(
count
(
distinct
case
when
t12_v
.
valid_call_num
>
0
then
t12_v
.
user_id
end
),
0
)
as
valid_call_dev_3
,
nvl
(
sum
(
t12_v
.
valid_call_num
),
0
)
as
valid_call_num_3
,
nvl
(
count
(
distinct
case
when
t6
.
call_num
>
0
then
t6
.
user_id
end
),
0
)
as
call_dev_kyc
,
nvl
(
sum
(
t6
.
call_num
),
0
)
as
call_num_kyc
,
nvl
(
count
(
distinct
case
when
t6_v
.
valid_call_num
>
0
then
t6_v
.
user_id
end
),
0
)
as
valid_call_dev_kyc
,
nvl
(
sum
(
t6_v
.
valid_call_num
),
0
)
as
valid_call_num_kyc
,
nvl
(
count
(
distinct
case
when
t9
.
call_num
>
0
then
t9
.
user_id
end
),
0
)
as
call_dev_qa
,
nvl
(
sum
(
t9
.
call_num
),
0
)
as
call_num_qa
,
nvl
(
count
(
distinct
case
when
t9_v
.
valid_call_num
>
0
then
t9_v
.
user_id
end
),
0
)
as
valid_call_dev_qa
,
nvl
(
sum
(
t9_v
.
valid_call_num
),
0
)
as
valid_call_num_qa
FROM
FROM
(
(
SELECT
partition_date
,
device_id
,
device_os_type
,
active_type
,
b
.
grey_type
SELECT
partition_date
,
device_id
,
device_os_type
,
b
.
active_type
,
b
.
grey_type
FROM
FROM
(
(
SELECT
SELECT
partition_date
partition_date
,
device_id
,
device_os_type
,
device_id
,
device_os_type
,
case
when
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
,
array
(
case
when
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
when
active_type
=
'4'
then
'老活跃设备'
end
as
active_type
when
active_type
=
'4'
then
'老活跃设备'
end
,
'合计'
)
as
active_type
,
array
(
case
when
substr
(
convup
(
setencryption
(
device_id
,
'sha-1'
),
16
,
10
),
-
2
,
2
)
%
20
=
0
then
'kyc灰度'
else
'非灰'
end
,
'合计'
)
as
grey_type
,
array
(
case
when
substr
(
convup
(
setencryption
(
device_id
,
'sha-1'
),
16
,
10
),
-
2
,
2
)
%
20
=
0
then
'kyc灰度'
else
'非灰'
end
,
'合计'
)
as
grey_type
FROM
online
.
ml_device_day_active_status
FROM
online
.
ml_device_day_active_status
where
partition_date
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
where
partition_date
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
...
@@ -120,6 +147,7 @@ FROM
...
@@ -120,6 +147,7 @@ FROM
and
device_id
is
not
null
and
device_id
is
not
null
)
a
)
a
LATERAL
VIEW
explode
(
a
.
grey_type
)
b
AS
grey_type
LATERAL
VIEW
explode
(
a
.
grey_type
)
b
AS
grey_type
LATERAL
VIEW
explode
(
a
.
active_type
)
b
AS
active_type
)
mas
)
mas
left
join
left
join
(
--找出user_id当天活跃的第一个设备id
(
--找出user_id当天活跃的第一个设备id
...
@@ -176,7 +204,111 @@ FROM
...
@@ -176,7 +204,111 @@ FROM
GROUP
BY
partition_date
,
user_id
GROUP
BY
partition_date
,
user_id
)
t2
)
t2
ON
a
.
partition_date
=
t2
.
partition_date
and
a
.
user_id
=
t2
.
user_id
ON
a
.
partition_date
=
t2
.
partition_date
and
a
.
user_id
=
t2
.
user_id
LEFT
JOIN
(
---拨打电话线索
SELECT
partition_date
,
user_id
,
count
(
1
)
as
call_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
)
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
GROUP
BY
user_id
,
partition_date
)
t3
ON
a
.
partition_date
=
t3
.
partition_date
and
a
.
user_id
=
t3
.
user_id
LEFT
JOIN
(
---拨打电话线索
SELECT
partition_date
,
user_id
,
count
(
1
)
as
valid_call_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
GROUP
BY
user_id
,
partition_date
)
t3_v
ON
a
.
partition_date
=
t3_v
.
partition_date
and
a
.
user_id
=
t3_v
.
user_id
left
join
left
join
(
--kyc私信
(
--kyc私信
SELECT
msg
.
partition_date
,
user_id
SELECT
msg
.
partition_date
,
user_id
...
@@ -289,7 +421,177 @@ FROM
...
@@ -289,7 +421,177 @@ FROM
group
by
partition_date
,
user_id
group
by
partition_date
,
user_id
)
t5
)
t5
ON
a
.
partition_date
=
t5
.
partition_date
and
a
.
user_id
=
t5
.
user_id
ON
a
.
partition_date
=
t5
.
partition_date
and
a
.
user_id
=
t5
.
user_id
LEFT
JOIN
(
--拨打电话线索
SELECT
partition_date
,
user_id
,
count
(
1
)
as
call_num
FROM
(
SELECT
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
AS
CALL_MONTH
,
MIN
(
a
.
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
)
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
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
partition_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
AND
source
=
'2'
--用户行为电话授权
group
by
id
,
user_id
,
merchant_id
,
created_time
)
e
ON
d
.
lead_task_id
=
e
.
id
join
(
SELECT
partition_date
,
user_id
,
merchant_id
from
(
SELECT
partition_date
,
cl_id
,
user_id
,
hospital_id
from
(
SELECT
partition_date
,
cl_id
,
user_id
,
json_split
(
params
[
'hospital_id'
],
'string'
)
as
hospital_ids
FROM
online
.
bl_hdfs_maidian_updates
where
partition_date
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
page_name
in
(
'kyc_phone'
)
and
action
=
'on_click_button'
and
params
[
'button_name'
]
=
'agree'
and
params
[
'hospital_id'
]
like
'%[%'
--其实传的是doctor_id
)
a
LATERAL
VIEW
explode
(
hospital_ids
)
b
AS
hospital_id
group
by
partition_date
,
cl_id
,
user_id
,
hospital_id
)
a
join
(
SELECT
doctor_id
,
merchant_id
FROM
online
.
ml_doctor_relation_dimen_day
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
doctor_is_merchant
=
'true'
--医生是商户
GROUP
BY
doctor_id
,
merchant_id
)
b
on
a
.
hospital_id
=
b
.
doctor_id
)
kyc
on
e
.
user_id
=
kyc
.
user_id
and
e
.
merchant_id
=
kyc
.
merchant_id
and
e
.
partition_date
=
kyc
.
partition_date
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
GROUP
BY
user_id
,
partition_date
)
t6
ON
a
.
partition_date
=
t6
.
partition_date
and
a
.
user_id
=
t6
.
user_id
LEFT
JOIN
(
---拨打电话线索
SELECT
partition_date
,
user_id
,
count
(
1
)
as
valid_call_num
FROM
(
SELECT
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
AS
CALL_MONTH
,
MIN
(
a
.
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
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
AND
source
=
'2'
--用户行为电话授权
group
by
id
,
user_id
,
merchant_id
,
created_time
)
e
ON
d
.
lead_task_id
=
e
.
id
join
(
SELECT
partition_date
,
user_id
,
merchant_id
from
(
SELECT
partition_date
,
cl_id
,
user_id
,
hospital_id
from
(
SELECT
partition_date
,
cl_id
,
user_id
,
json_split
(
params
[
'hospital_id'
],
'string'
)
as
hospital_ids
FROM
online
.
bl_hdfs_maidian_updates
where
partition_date
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
page_name
in
(
'kyc_phone'
)
and
action
=
'on_click_button'
and
params
[
'button_name'
]
=
'agree'
and
params
[
'hospital_id'
]
like
'%[%'
--其实传的是doctor_id
)
a
LATERAL
VIEW
explode
(
hospital_ids
)
b
AS
hospital_id
group
by
partition_date
,
cl_id
,
user_id
,
hospital_id
)
a
join
(
SELECT
doctor_id
,
merchant_id
FROM
online
.
ml_doctor_relation_dimen_day
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
doctor_is_merchant
=
'true'
--医生是商户
GROUP
BY
doctor_id
,
merchant_id
)
b
on
a
.
hospital_id
=
b
.
doctor_id
)
kyc
on
e
.
user_id
=
kyc
.
user_id
and
e
.
merchant_id
=
kyc
.
merchant_id
and
e
.
created_date
=
kyc
.
partition_date
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
GROUP
BY
user_id
,
partition_date
)
t6_v
ON
a
.
partition_date
=
t6_v
.
partition_date
and
a
.
user_id
=
t6_v
.
user_id
left
join
left
join
(
--需求自测私信
(
--需求自测私信
SELECT
msg
.
partition_date
,
user_id
SELECT
msg
.
partition_date
,
user_id
...
@@ -373,45 +675,180 @@ FROM
...
@@ -373,45 +675,180 @@ FROM
)
b
)
b
join
join
(
(
SELECT
hospital_id
,
merchant_id
SELECT
hospital_id
,
merchant_id
FROM
online
.
ml_doctor_relation_dimen_day
FROM
online
.
ml_doctor_relation_dimen_day
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
WHERE
partition_date
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
doctor_is_merchant
=
'true'
--医生是商户
AND
doctor_is_merchant
=
'true'
--医生是商户
GROUP
BY
hospital_id
,
merchant_id
GROUP
BY
hospital_id
,
merchant_id
)
c
)
c
on
c
.
hospital_id
=
b
.
hospital_id
on
c
.
hospital_id
=
b
.
hospital_id
group
by
partition_date
,
user_id
,
merchant_id
group
by
partition_date
,
user_id
,
merchant_id
)
a
join
(
SELECT
user_id
,
merchant_id
,
partition_day
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
,
partition_day
)
b
on
a
.
user_id
=
b
.
user_id
and
a
.
merchant_id
=
b
.
merchant_id
and
a
.
partition_date
=
b
.
partition_day
group
by
a
.
user_id
,
a
.
merchant_id
,
substr
(
partition_day
,
1
,
6
)
)
msg
group
by
msg
.
partition_date
,
user_id
)
t7_v
on
a
.
partition_date
=
t7_v
.
partition_date
and
a
.
user_id
=
t7_v
.
user_id
LEFT
JOIN
(
--需求自测电话线索总数
SELECT
partition_date
,
user_id
,
count
(
1
)
as
clue_num
FROM
(
SELECT
a
.
user_id
,
a
.
merchant_id
,
substr
(
a
.
partition_date
,
1
,
6
)
as
month
,
min
(
a
.
partition_date
)
as
partition_date
FROM
(
SELECT
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
partition_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
AND
source
=
'2'
--用户行为电话授权
GROUP
BY
user_id
,
merchant_id
,
regexp_replace
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
)
a
join
(
SELECT
partition_date
,
cl_id
,
user_id
FROM
online
.
bl_hdfs_maidian_updates
where
partition_date
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
params
[
'popup_name'
]
=
'bargain_phone'
and
page_name
=
'ai_plan_list'
and
params
[
'button_name'
]
in
(
'confirm'
)
and
action
=
'on_click_button'
and
int
(
split
(
app_version
,
'
\\
.'
)[
1
])
>=
31
)
ai
on
a
.
user_id
=
ai
.
user_id
and
a
.
partition_date
=
ai
.
partition_date
GROUP
BY
a
.
user_id
,
a
.
merchant_id
,
substr
(
a
.
partition_date
,
1
,
6
)
)
a
group
by
partition_date
,
user_id
)
t8
ON
a
.
partition_date
=
t8
.
partition_date
and
a
.
user_id
=
t8
.
user_id
LEFT
JOIN
(
---拨打电话线索
SELECT
partition_date
,
user_id
,
count
(
1
)
as
call_num
FROM
(
SELECT
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
AS
CALL_MONTH
,
MIN
(
a
.
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
)
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
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
AND
source
=
'2'
--用户行为电话授权
group
by
id
,
user_id
,
merchant_id
,
created_time
)
e
ON
d
.
lead_task_id
=
e
.
id
join
(
SELECT
partition_date
,
cl_id
,
user_id
FROM
online
.
bl_hdfs_maidian_updates
where
partition_date
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
params
[
'popup_name'
]
=
'bargain_phone'
and
page_name
=
'ai_plan_list'
and
params
[
'button_name'
]
in
(
'confirm'
)
and
action
=
'on_click_button'
and
int
(
split
(
app_version
,
'
\\
.'
)[
1
])
>=
31
)
ai
on
e
.
user_id
=
ai
.
user_id
and
e
.
created_date
=
ai
.
partition_date
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
GROUP
BY
user_id
,
partition_date
)
t9
ON
a
.
partition_date
=
t9
.
partition_date
and
a
.
user_id
=
t9
.
user_id
LEFT
JOIN
(
---拨打电话线索
SELECT
partition_date
,
user_id
,
count
(
1
)
as
valid_call_num
FROM
(
SELECT
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
AS
CALL_MONTH
,
MIN
(
a
.
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
)
a
join
LEFT
JOIN
(
(
SELECT
user_id
,
merchant_id
,
partition_day
SELECT
id
,
sub_id
FROM
ml
.
ml_c_et_msg_conversation_dimen_inc_d
--新仓库私信表
FROM
tl
.
tl_gm_sl_ali_virtual_phone_binding
--阿里记录表
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
and
is_valid
=
'true'
GROUP
BY
user_id
,
merchant_id
,
partition_day
)
b
)
b
on
a
.
user_id
=
b
.
user_id
and
a
.
merchant_id
=
b
.
merchant_id
and
a
.
partition_date
=
b
.
partition_day
ON
a
.
sub_id
=
b
.
sub_id
group
by
a
.
user_id
,
a
.
merchant_id
,
substr
(
partition_day
,
1
,
6
)
)
msg
group
by
msg
.
partition_date
,
user_id
)
t7_v
on
a
.
partition_date
=
t7_v
.
partition_date
and
a
.
user_id
=
t7_v
.
user_id
LEFT
JOIN
LEFT
JOIN
(
--需求自测电话线索总数
SELECT
partition_date
,
user_id
,
count
(
1
)
as
clue_num
FROM
(
(
SELECT
a
.
user_id
,
a
.
merchant_id
,
substr
(
a
.
partition_date
,
1
,
6
)
as
month
,
min
(
a
.
partition_date
)
as
partition_date
SELECT
id
,
platform_binding_id
FROM
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
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
partition_date
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
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
AND
source
=
'2'
--用户行为电话授权
AND
source
=
'2'
--用户行为电话授权
GROUP
BY
user_id
,
merchant_id
,
regexp_replace
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
group
by
id
,
user_id
,
merchant_id
,
created_time
)
a
)
e
ON
d
.
lead_task_id
=
e
.
id
join
join
(
(
SELECT
partition_date
,
cl_id
,
user_id
SELECT
partition_date
,
cl_id
,
user_id
...
@@ -424,15 +861,14 @@ FROM
...
@@ -424,15 +861,14 @@ FROM
and
action
=
'on_click_button'
and
action
=
'on_click_button'
and
int
(
split
(
app_version
,
'
\\
.'
)[
1
])
>=
31
and
int
(
split
(
app_version
,
'
\\
.'
)[
1
])
>=
31
)
ai
)
ai
on
a
.
user_id
=
ai
.
user_id
and
a
.
partition_date
=
ai
.
partition_date
on
e
.
user_id
=
ai
.
user_id
and
e
.
created_date
=
ai
.
partition_date
GROUP
BY
a
.
user_id
,
a
.
merchant_id
,
substr
(
a
.
partition_date
,
1
,
6
)
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
a
)
t1
group
by
partition_date
,
user_id
GROUP
BY
user_id
,
partition_date
)
t8
)
t9_v
ON
a
.
partition_date
=
t8
.
partition_date
and
a
.
user_id
=
t8
.
user_id
ON
a
.
partition_date
=
t9_v
.
partition_date
and
a
.
user_id
=
t9_v
.
user_id
left
join
left
join
(
--t
4
以上商户私信线索总数
(
--t
3
以上商户私信线索总数
SELECT
msg
.
partition_date
,
user_id
SELECT
msg
.
partition_date
,
user_id
,
count
(
msg
.
merchant_id
)
as
msg_num
,
count
(
msg
.
merchant_id
)
as
msg_num
FROM
FROM
...
@@ -460,7 +896,7 @@ FROM
...
@@ -460,7 +896,7 @@ FROM
)
t10
)
t10
ON
a
.
partition_date
=
t10
.
partition_date
and
a
.
user_id
=
t10
.
user_id
ON
a
.
partition_date
=
t10
.
partition_date
and
a
.
user_id
=
t10
.
user_id
left
join
left
join
(
--t
4
以上商户有效私信线索总数
(
--t
3
以上商户有效私信线索总数
SELECT
msg
.
partition_date
,
user_id
SELECT
msg
.
partition_date
,
user_id
,
count
(
msg
.
merchant_id
)
as
valid_msg_num
,
count
(
msg
.
merchant_id
)
as
valid_msg_num
FROM
FROM
...
@@ -489,7 +925,7 @@ FROM
...
@@ -489,7 +925,7 @@ FROM
)
t10_v
)
t10_v
ON
a
.
partition_date
=
t10_v
.
partition_date
and
a
.
user_id
=
t10_v
.
user_id
ON
a
.
partition_date
=
t10_v
.
partition_date
and
a
.
user_id
=
t10_v
.
user_id
left
join
left
join
(
--t
4
以上商户电话线索总数
(
--t
3
以上商户电话线索总数
SELECT
partition_date
,
user_id
,
count
(
1
)
AS
clue_num
SELECT
partition_date
,
user_id
,
count
(
1
)
AS
clue_num
FROM
FROM
(
(
...
@@ -516,40 +952,174 @@ FROM
...
@@ -516,40 +952,174 @@ FROM
GROUP
BY
partition_date
,
user_id
GROUP
BY
partition_date
,
user_id
)
t11
)
t11
ON
a
.
partition_date
=
t11
.
partition_date
and
a
.
user_id
=
t11
.
user_id
ON
a
.
partition_date
=
t11
.
partition_date
and
a
.
user_id
=
t11
.
user_id
LEFT
JOIN
(
---拨打电话线索
SELECT
partition_date
,
user_id
,
count
(
1
)
as
call_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
)
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
)
t12
ON
a
.
partition_date
=
t12
.
partition_date
and
a
.
user_id
=
t12
.
user_id
LEFT
JOIN
(
---拨打有效电话线索
SELECT
partition_date
,
user_id
,
count
(
1
)
as
valid_call_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
)
t12_v
ON
a
.
partition_date
=
t12_v
.
partition_date
and
a
.
user_id
=
t12_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
(
(
SELECT
t3
.
partition_date
,
a
.
device_os_type
,
a
.
grey_type
SELECT
t3_d
.
partition_date
,
a
.
device_os_type
,
a
.
grey_type
,
case
when
b
.
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
,
a
.
active_type
when
(
b
.
active_type
=
'4'
or
b
.
active_type
is
null
)
then
'老活跃设备'
end
as
active_type
,
nvl
(
count
(
distinct
case
when
t3_d
.
call_num
>
0
then
t3_d
.
user_id
end
),
0
)
as
call_dev_d
,
nvl
(
count
(
distinct
case
when
t3
.
call_num
>
0
then
t3
.
user_id
end
),
0
)
as
call_dev
,
nvl
(
sum
(
t3_d
.
call_num
),
0
)
as
call_num_d
,
nvl
(
sum
(
t3
.
call_num
),
0
)
as
call_num
,
nvl
(
count
(
distinct
case
when
t3_v
.
valid_call_num
>
0
then
t3_v
.
user_id
end
),
0
)
as
valid_call_dev
,
nvl
(
sum
(
t3_v
.
valid_call_num
),
0
)
as
valid_call_num
,
nvl
(
count
(
distinct
case
when
t12
.
call_num
>
0
then
t12
.
user_id
end
),
0
)
as
call_dev_4
,
nvl
(
count
(
distinct
case
when
t3_v_d
.
valid_call_num
>
0
then
t3_v_d
.
user_id
end
),
0
)
as
valid_call_dev_d
,
nvl
(
sum
(
t12
.
call_num
),
0
)
as
call_num_4
,
nvl
(
sum
(
t3_v_d
.
valid_call_num
),
0
)
as
valid_call_num_d
,
nvl
(
count
(
distinct
case
when
t12_v
.
valid_call_num
>
0
then
t12_v
.
user_id
end
),
0
)
as
valid_call_dev_4
,
nvl
(
sum
(
t12_v
.
valid_call_num
),
0
)
as
valid_call_num_4
,
nvl
(
count
(
distinct
case
when
t6
.
call_num
>
0
then
t6
.
user_id
end
),
0
)
as
call_dev_kyc
,
nvl
(
count
(
distinct
case
when
t12_d
.
call_num
>
0
then
t12_d
.
user_id
end
),
0
)
as
call_dev_3_d
,
nvl
(
sum
(
t6
.
call_num
),
0
)
as
call_num_kyc
,
nvl
(
sum
(
t12_d
.
call_num
),
0
)
as
call_num_3_d
,
nvl
(
count
(
distinct
case
when
t6_v
.
valid_call_num
>
0
then
t6_v
.
user_id
end
),
0
)
as
valid_call_dev_kyc
,
nvl
(
sum
(
t6_v
.
valid_call_num
),
0
)
as
valid_call_num_kyc
,
nvl
(
count
(
distinct
case
when
t9
.
call_num
>
0
then
t9
.
user_id
end
),
0
)
as
call_dev_qa
,
nvl
(
count
(
distinct
case
when
t12_v_d
.
valid_call_num
>
0
then
t12_v_d
.
user_id
end
),
0
)
as
valid_call_dev_3_d
,
nvl
(
sum
(
t9
.
call_num
),
0
)
as
call_num_qa
,
nvl
(
sum
(
t12_v_d
.
valid_call_num
),
0
)
as
valid_call_num_3_d
,
nvl
(
count
(
distinct
case
when
t9_v
.
valid_call_num
>
0
then
t9_v
.
user_id
end
),
0
)
as
valid_call_dev_qa
,
nvl
(
sum
(
t9_v
.
valid_call_num
),
0
)
as
valid_call_num_qa
,
nvl
(
count
(
distinct
case
when
t6_d
.
call_num
>
0
then
t6_d
.
user_id
end
),
0
)
as
call_dev_kyc_d
,
nvl
(
sum
(
t6_d
.
call_num
),
0
)
as
call_num_kyc_d
,
nvl
(
count
(
distinct
case
when
t6_v_d
.
valid_call_num
>
0
then
t6_v_d
.
user_id
end
),
0
)
as
valid_call_dev_kyc_d
,
nvl
(
sum
(
t6_v_d
.
valid_call_num
),
0
)
as
valid_call_num_kyc_d
,
nvl
(
count
(
distinct
case
when
t9_d
.
call_num
>
0
then
t9_d
.
user_id
end
),
0
)
as
call_dev_qa_d
,
nvl
(
sum
(
t9_d
.
call_num
),
0
)
as
call_num_qa_d
,
nvl
(
count
(
distinct
case
when
t9_v_d
.
valid_call_num
>
0
then
t9_v_d
.
user_id
end
),
0
)
as
valid_call_dev_qa_d
,
nvl
(
sum
(
t9_v_d
.
valid_call_num
),
0
)
as
valid_call_num_qa_d
FROM
FROM
(
(
SELECT
device_id
,
device_os_type
,
user_id
,
v
.
grey_type
SELECT
device_id
,
device_os_type
,
user_id
,
v
.
grey_type
,
v
.
active_type
FROM
FROM
(
(
SELECT
device_id
,
device_os_type
,
user_id
SELECT
device_id
,
device_os_type
,
user_id
,
array
(
case
when
substr
(
convup
(
setencryption
(
device_id
,
'sha-1'
),
16
,
10
),
-
2
,
2
)
%
20
=
0
then
'kyc灰度'
else
'非灰'
end
,
'合计'
)
as
grey_type
,
array
(
case
when
substr
(
convup
(
setencryption
(
device_id
,
'sha-1'
),
16
,
10
),
-
2
,
2
)
%
20
=
0
then
'kyc灰度'
else
'非灰'
end
,
'合计'
)
as
grey_type
,
array
(
'老活跃设备'
,
'合计'
)
as
active_type
FROM
FROM
(
(
SELECT
device_id
,
device_os_type
,
a
.
user_id
,
a
.
partition_date
SELECT
device_id
,
device_os_type
,
a
.
user_id
,
a
.
partition_date
...
@@ -575,9 +1145,10 @@ LEFT JOIN
...
@@ -575,9 +1145,10 @@ LEFT JOIN
where
rn
=
1
where
rn
=
1
)
d
)
d
LATERAL
VIEW
EXPLODE
(
d
.
grey_type
)
v
as
grey_type
LATERAL
VIEW
EXPLODE
(
d
.
grey_type
)
v
as
grey_type
LATERAL
VIEW
EXPLODE
(
d
.
active_type
)
v
as
active_type
)
a
)
a
JOIN
JOIN
(
---拨打电话线索
(
---
非当天
拨打电话线索
SELECT
partition_date
,
user_id
SELECT
partition_date
,
user_id
,
count
(
1
)
as
call_num
,
count
(
1
)
as
call_num
FROM
FROM
...
@@ -617,31 +1188,20 @@ LEFT JOIN
...
@@ -617,31 +1188,20 @@ LEFT JOIN
ON
c
.
id
=
d
.
phone_binding_id
ON
c
.
id
=
d
.
phone_binding_id
JOIN
JOIN
(
(
SELECT
id
,
user_id
,
merchant_id
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
source
=
'2'
--用户行为电话授权
AND
source
=
'2'
--用户行为电话授权
)
e
)
e
ON
d
.
lead_task_id
=
e
.
id
ON
d
.
lead_task_id
=
e
.
id
where
a
.
partition_date
<>
e
.
created_date
GROUP
BY
user_id
,
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
GROUP
BY
user_id
,
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
)
t1
GROUP
BY
user_id
,
partition_date
GROUP
BY
user_id
,
partition_date
)
t3
)
t3_d
ON
a
.
user_id
=
t3
.
user_id
ON
a
.
user_id
=
t3_d
.
user_id
left
join
(
SELECT
partition_date
,
device_id
,
active_type
FROM
online
.
ml_device_day_active_status
where
partition_date
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_date
<=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
)
b
on
t3
.
partition_date
=
b
.
partition_date
and
a
.
device_id
=
b
.
device_id
LEFT
JOIN
LEFT
JOIN
(
---
拨打
电话线索
(
---
非当天拨打有效
电话线索
SELECT
partition_date
,
user_id
SELECT
partition_date
,
user_id
,
count
(
1
)
as
valid_call_num
,
count
(
1
)
as
valid_call_num
FROM
FROM
...
@@ -682,17 +1242,19 @@ LEFT JOIN
...
@@ -682,17 +1242,19 @@ LEFT JOIN
ON
c
.
id
=
d
.
phone_binding_id
ON
c
.
id
=
d
.
phone_binding_id
JOIN
JOIN
(
(
SELECT
id
,
user_id
,
merchant_id
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
source
=
'2'
--用户行为电话授权
AND
source
=
'2'
--用户行为电话授权
)
e
)
e
ON
d
.
lead_task_id
=
e
.
id
ON
d
.
lead_task_id
=
e
.
id
where
a
.
partition_date
<>
e
.
created_date
GROUP
BY
user_id
,
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
GROUP
BY
user_id
,
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
)
t1
GROUP
BY
user_id
,
partition_date
GROUP
BY
user_id
,
partition_date
)
t3_v
)
t3_v_d
ON
t3
.
partition_date
=
t3_v
.
partition_date
and
t3
.
user_id
=
t3_v
.
user_id
ON
t3_d
.
partition_date
=
t3_v_d
.
partition_date
and
t3_d
.
user_id
=
t3_v_d
.
user_id
LEFT
JOIN
LEFT
JOIN
(
--拨打电话线索
(
--拨打电话线索
SELECT
partition_date
,
user_id
SELECT
partition_date
,
user_id
...
@@ -734,7 +1296,7 @@ LEFT JOIN
...
@@ -734,7 +1296,7 @@ LEFT JOIN
ON
c
.
id
=
d
.
phone_binding_id
ON
c
.
id
=
d
.
phone_binding_id
JOIN
JOIN
(
(
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
partition
_date
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created
_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
...
@@ -772,12 +1334,14 @@ LEFT JOIN
...
@@ -772,12 +1334,14 @@ LEFT JOIN
)
b
)
b
on
a
.
hospital_id
=
b
.
doctor_id
on
a
.
hospital_id
=
b
.
doctor_id
)
kyc
)
kyc
on
e
.
user_id
=
kyc
.
user_id
and
e
.
merchant_id
=
kyc
.
merchant_id
and
e
.
partition_date
=
kyc
.
partition_date
on
e
.
user_id
=
kyc
.
user_id
and
e
.
merchant_id
=
kyc
.
merchant_id
and
e
.
created_date
=
kyc
.
partition_date
where
a
.
partition_date
<>
e
.
created_date
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
)
t1
GROUP
BY
user_id
,
partition_date
GROUP
BY
user_id
,
partition_date
)
t6
)
t6_d
ON
t3
.
partition_date
=
t6
.
partition_date
and
t3
.
user_id
=
t6
.
user_id
ON
t3_d
.
partition_date
=
t6_d
.
partition_date
and
t3_d
.
user_id
=
t6_d
.
user_id
LEFT
JOIN
LEFT
JOIN
(
---拨打电话线索
(
---拨打电话线索
SELECT
partition_date
,
user_id
SELECT
partition_date
,
user_id
...
@@ -820,7 +1384,7 @@ LEFT JOIN
...
@@ -820,7 +1384,7 @@ LEFT JOIN
ON
c
.
id
=
d
.
phone_binding_id
ON
c
.
id
=
d
.
phone_binding_id
JOIN
JOIN
(
(
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
partition
_date
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created
_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
...
@@ -858,12 +1422,14 @@ LEFT JOIN
...
@@ -858,12 +1422,14 @@ LEFT JOIN
)
b
)
b
on
a
.
hospital_id
=
b
.
doctor_id
on
a
.
hospital_id
=
b
.
doctor_id
)
kyc
)
kyc
on
e
.
user_id
=
kyc
.
user_id
and
e
.
merchant_id
=
kyc
.
merchant_id
and
e
.
partition_date
=
kyc
.
partition_date
on
e
.
user_id
=
kyc
.
user_id
and
e
.
merchant_id
=
kyc
.
merchant_id
and
e
.
created_date
=
kyc
.
partition_date
where
a
.
partition_date
<>
e
.
created_date
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
)
t1
GROUP
BY
user_id
,
partition_date
GROUP
BY
user_id
,
partition_date
)
t6_v
)
t6_v_d
ON
t3
.
partition_date
=
t6_v
.
partition_date
and
t3
.
user_id
=
t6_v
.
user_id
ON
t3_d
.
partition_date
=
t6_v_d
.
partition_date
and
t3_d
.
user_id
=
t6_v_d
.
user_id
LEFT
JOIN
LEFT
JOIN
(
---拨打电话线索
(
---拨打电话线索
SELECT
partition_date
,
user_id
SELECT
partition_date
,
user_id
...
@@ -905,7 +1471,7 @@ LEFT JOIN
...
@@ -905,7 +1471,7 @@ LEFT JOIN
ON
c
.
id
=
d
.
phone_binding_id
ON
c
.
id
=
d
.
phone_binding_id
JOIN
JOIN
(
(
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
partition
_date
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created
_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
...
@@ -925,14 +1491,16 @@ LEFT JOIN
...
@@ -925,14 +1491,16 @@ LEFT JOIN
and
action
=
'on_click_button'
and
action
=
'on_click_button'
and
int
(
split
(
app_version
,
'
\\
.'
)[
1
])
>=
31
and
int
(
split
(
app_version
,
'
\\
.'
)[
1
])
>=
31
)
ai
)
ai
on
e
.
user_id
=
ai
.
user_id
and
e
.
partition_date
=
ai
.
partition_date
on
e
.
user_id
=
ai
.
user_id
and
e
.
created_date
=
ai
.
partition_date
where
a
.
partition_date
<>
e
.
created_date
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
)
t1
GROUP
BY
user_id
,
partition_date
GROUP
BY
user_id
,
partition_date
)
t9
)
t9_d
ON
t3
.
partition_date
=
t9
.
partition_date
and
t3
.
user_id
=
t9
.
user_id
ON
t3_d
.
partition_date
=
t9_d
.
partition_date
and
t3_d
.
user_id
=
t9_d
.
user_id
LEFT
JOIN
LEFT
JOIN
(
---
有效
电话线索
(
---
拨打
电话线索
SELECT
partition_date
,
user_id
SELECT
partition_date
,
user_id
,
count
(
1
)
as
valid_call_num
,
count
(
1
)
as
valid_call_num
FROM
FROM
...
@@ -973,7 +1541,7 @@ LEFT JOIN
...
@@ -973,7 +1541,7 @@ LEFT JOIN
ON
c
.
id
=
d
.
phone_binding_id
ON
c
.
id
=
d
.
phone_binding_id
JOIN
JOIN
(
(
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
partition
_date
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created
_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
WHERE
partition_day
>=
REGEXP_REPLACE
(
trunc
(
date_sub
(
current_date
(),
1
),
'MM'
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
AND
partition_day
<=
regexp_replace
(
date_sub
(
current_date
(),
1
),
'-'
,
''
)
...
@@ -993,12 +1561,14 @@ LEFT JOIN
...
@@ -993,12 +1561,14 @@ LEFT JOIN
and
action
=
'on_click_button'
and
action
=
'on_click_button'
and
int
(
split
(
app_version
,
'
\\
.'
)[
1
])
>=
31
and
int
(
split
(
app_version
,
'
\\
.'
)[
1
])
>=
31
)
ai
)
ai
on
e
.
user_id
=
ai
.
user_id
and
e
.
partition_date
=
ai
.
partition_date
on
e
.
user_id
=
ai
.
user_id
and
e
.
created_date
=
ai
.
partition_date
where
a
.
partition_date
<>
e
.
created_date
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
GROUP
BY
e
.
user_id
,
e
.
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
)
t1
GROUP
BY
user_id
,
partition_date
GROUP
BY
user_id
,
partition_date
)
t9_v
)
t9_v_d
ON
t3
.
partition_date
=
t9_v
.
partition_date
and
t3
.
user_id
=
t9_v
.
user_id
ON
t3_d
.
partition_date
=
t9_v_d
.
partition_date
and
t3_d
.
user_id
=
t9_v_d
.
user_id
LEFT
JOIN
LEFT
JOIN
(
---拨打电话线索
(
---拨打电话线索
SELECT
partition_date
,
user_id
SELECT
partition_date
,
user_id
...
@@ -1040,12 +1610,13 @@ LEFT JOIN
...
@@ -1040,12 +1610,13 @@ LEFT JOIN
ON
c
.
id
=
d
.
phone_binding_id
ON
c
.
id
=
d
.
phone_binding_id
JOIN
JOIN
(
(
SELECT
id
,
user_id
,
merchant_id
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
source
=
'2'
--用户行为电话授权
AND
source
=
'2'
--用户行为电话授权
)
e
)
e
ON
d
.
lead_task_id
=
e
.
id
ON
d
.
lead_task_id
=
e
.
id
where
a
.
partition_date
<>
e
.
created_date
GROUP
BY
user_id
,
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
GROUP
BY
user_id
,
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
)
t1
join
join
...
@@ -1062,8 +1633,9 @@ LEFT JOIN
...
@@ -1062,8 +1633,9 @@ LEFT JOIN
)
b
)
b
on
t1
.
merchant_id
=
b
.
merchant_id
on
t1
.
merchant_id
=
b
.
merchant_id
GROUP
BY
user_id
,
partition_date
GROUP
BY
user_id
,
partition_date
)
t12
)
t12_d
ON
t3
.
partition_date
=
t12
.
partition_date
and
t3
.
user_id
=
t12
.
user_id
ON
t3_d
.
partition_date
=
t12_d
.
partition_date
and
t3_d
.
user_id
=
t12_d
.
user_id
LEFT
JOIN
LEFT
JOIN
(
---拨打有效电话线索
(
---拨打有效电话线索
SELECT
partition_date
,
user_id
SELECT
partition_date
,
user_id
...
@@ -1106,12 +1678,13 @@ LEFT JOIN
...
@@ -1106,12 +1678,13 @@ LEFT JOIN
ON
c
.
id
=
d
.
phone_binding_id
ON
c
.
id
=
d
.
phone_binding_id
JOIN
JOIN
(
(
SELECT
id
,
user_id
,
merchant_id
SELECT
id
,
user_id
,
merchant_id
,
REGEXP_REPLACE
(
SUBSTR
(
created_time
,
1
,
10
),
'-'
,
''
)
as
created_date
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
FROM
tl
.
tl_gm_sl_lead_task
--线索任务表(用户点击授权后记入该表)
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
WHERE
partition_day
=
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
)
AND
source
=
'2'
--用户行为电话授权
AND
source
=
'2'
--用户行为电话授权
)
e
)
e
ON
d
.
lead_task_id
=
e
.
id
ON
d
.
lead_task_id
=
e
.
id
where
a
.
partition_date
<>
e
.
created_date
GROUP
BY
user_id
,
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
GROUP
BY
user_id
,
merchant_id
,
regexp_replace
(
SUBSTR
(
a
.
partition_date
,
1
,
6
),
'-'
,
''
)
)
t1
)
t1
join
join
...
@@ -1128,10 +1701,9 @@ LEFT JOIN
...
@@ -1128,10 +1701,9 @@ LEFT JOIN
)
b
)
b
on
t1
.
merchant_id
=
b
.
merchant_id
on
t1
.
merchant_id
=
b
.
merchant_id
GROUP
BY
user_id
,
partition_date
GROUP
BY
user_id
,
partition_date
)
t12_v
)
t12_v_d
ON
t3
.
partition_date
=
t12_v
.
partition_date
and
t3
.
user_id
=
t12_v
.
user_id
ON
t3_d
.
partition_date
=
t12_v_d
.
partition_date
and
t3_d
.
user_id
=
t12_v_d
.
user_id
group
by
t3
.
partition_date
,
a
.
device_os_type
,
a
.
grey_type
,
case
when
b
.
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
group
by
t3_d
.
partition_date
,
a
.
device_os_type
,
a
.
grey_type
,
a
.
active_type
when
(
b
.
active_type
=
'4'
or
b
.
active_type
is
null
)
then
'老活跃设备'
end
)
T2
)
T2
on
T1
.
partition_date
=
T2
.
partition_date
on
T1
.
partition_date
=
T2
.
partition_date
AND
T1
.
device_os_type
=
T2
.
device_os_type
AND
T1
.
device_os_type
=
T2
.
device_os_type
...
...
pm/clue_daily/etl/create_clue_daily.sql
View file @
a371d573
...
@@ -28,21 +28,29 @@ CREATE TABLE IF NOT EXISTS pm.tl_pm_userclue_d
...
@@ -28,21 +28,29 @@ CREATE TABLE IF NOT EXISTS pm.tl_pm_userclue_d
valid_msg_num
bigint
comment
'{"chs_name":"有效私信咨询人次-总计","description":"","etl":"","value":"","remark":""}'
,
valid_msg_num
bigint
comment
'{"chs_name":"有效私信咨询人次-总计","description":"","etl":"","value":"","remark":""}'
,
clue_dev
bigint
comment
'{"chs_name":"授权电话线索设备数-总计","description":"","etl":"","value":"","remark":""}'
,
clue_dev
bigint
comment
'{"chs_name":"授权电话线索设备数-总计","description":"","etl":"","value":"","remark":""}'
,
clue_num
bigint
comment
'{"chs_name":"授权电话线索人次-总计","description":"","etl":"","value":"","remark":""}'
,
clue_num
bigint
comment
'{"chs_name":"授权电话线索人次-总计","description":"","etl":"","value":"","remark":""}'
,
call_dev
bigint
comment
'{"chs_name":"拨打电话线索设备数-总计","description":"","etl":"","value":"","remark":""}'
,
call_dev
bigint
comment
'{"chs_name":"当天拨打电话线索设备数-总计","description":"","etl":"","value":"","remark":""}'
,
call_num
bigint
comment
'{"chs_name":"拨打电话线索人次-总计","description":"","etl":"","value":"","remark":""}'
,
call_num
bigint
comment
'{"chs_name":"当天拨打电话线索人次-总计","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev
bigint
comment
'{"chs_name":"有效电话线索设备数-总计","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev
bigint
comment
'{"chs_name":"当天有效电话线索设备数-总计","description":"","etl":"","value":"","remark":""}'
,
valid_call_num
bigint
comment
'{"chs_name":"有效电话线索人次-总计","description":"","etl":"","value":"","remark":""}'
,
valid_call_num
bigint
comment
'{"chs_name":"当天有效电话线索人次-总计","description":"","etl":"","value":"","remark":""}'
,
call_dev_d
bigint
comment
'{"chs_name":"非当天拨打电话线索设备数-总计","description":"","etl":"","value":"","remark":""}'
,
call_num_d
bigint
comment
'{"chs_name":"非当天拨打电话线索人次-总计","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev_d
bigint
comment
'{"chs_name":"非当天有效电话线索设备数-总计","description":"","etl":"","value":"","remark":""}'
,
valid_call_num_d
bigint
comment
'{"chs_name":"非当天有效电话线索人次-总计","description":"","etl":"","value":"","remark":""}'
,
msg_dev_4
bigint
comment
'{"chs_name":"私信咨询设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
msg_dev_3
bigint
comment
'{"chs_name":"私信咨询设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
msg_num_4
bigint
comment
'{"chs_name":"私信咨询人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
msg_num_3
bigint
comment
'{"chs_name":"私信咨询人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
valid_msg_dev_4
bigint
comment
'{"chs_name":"有效私信咨询设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
valid_msg_dev_3
bigint
comment
'{"chs_name":"有效私信咨询设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
valid_msg_num_4
bigint
comment
'{"chs_name":"有效私信咨询人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
valid_msg_num_3
bigint
comment
'{"chs_name":"有效私信咨询人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
clue_dev_4
bigint
comment
'{"chs_name":"授权电话线索设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
clue_dev_3
bigint
comment
'{"chs_name":"授权电话线索设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
clue_num_4
bigint
comment
'{"chs_name":"授权电话线索人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
clue_num_3
bigint
comment
'{"chs_name":"授权电话线索人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
call_dev_4
bigint
comment
'{"chs_name":"拨打电话线索设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
call_dev_3
bigint
comment
'{"chs_name":"当天拨打电话线索设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
call_num_4
bigint
comment
'{"chs_name":"拨打电话线索人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
call_num_3
bigint
comment
'{"chs_name":"当天拨打电话线索人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev_4
bigint
comment
'{"chs_name":"有效电话线索设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev_3
bigint
comment
'{"chs_name":"当天有效电话线索设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
valid_call_num_4
bigint
comment
'{"chs_name":"有效电话线索人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
valid_call_num_3
bigint
comment
'{"chs_name":"当天有效电话线索人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
call_dev_3_d
bigint
comment
'{"chs_name":"非当天拨打电话线索设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
call_num_3_d
bigint
comment
'{"chs_name":"非当天拨打电话线索人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev_3_d
bigint
comment
'{"chs_name":"非当天有效电话线索设备数-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
valid_call_num_3_d
bigint
comment
'{"chs_name":"非当天有效电话线索人次-4级以上商户","description":"","etl":"","value":"","remark":""}'
,
msg_dev_kyc
bigint
comment
'{"chs_name":"私信咨询设备数-kyc","description":"","etl":"","value":"","remark":""}'
,
msg_dev_kyc
bigint
comment
'{"chs_name":"私信咨询设备数-kyc","description":"","etl":"","value":"","remark":""}'
,
msg_num_kyc
bigint
comment
'{"chs_name":"私信咨询人次-kyc","description":"","etl":"","value":"","remark":""}'
,
msg_num_kyc
bigint
comment
'{"chs_name":"私信咨询人次-kyc","description":"","etl":"","value":"","remark":""}'
,
...
@@ -50,10 +58,14 @@ CREATE TABLE IF NOT EXISTS pm.tl_pm_userclue_d
...
@@ -50,10 +58,14 @@ CREATE TABLE IF NOT EXISTS pm.tl_pm_userclue_d
valid_msg_num_kyc
bigint
comment
'{"chs_name":"有效私信咨询人次-kyc","description":"","etl":"","value":"","remark":""}'
,
valid_msg_num_kyc
bigint
comment
'{"chs_name":"有效私信咨询人次-kyc","description":"","etl":"","value":"","remark":""}'
,
clue_dev_kyc
bigint
comment
'{"chs_name":"授权电话线索设备数-kyc","description":"","etl":"","value":"","remark":""}'
,
clue_dev_kyc
bigint
comment
'{"chs_name":"授权电话线索设备数-kyc","description":"","etl":"","value":"","remark":""}'
,
clue_num_kyc
bigint
comment
'{"chs_name":"授权电话线索人次-kyc","description":"","etl":"","value":"","remark":""}'
,
clue_num_kyc
bigint
comment
'{"chs_name":"授权电话线索人次-kyc","description":"","etl":"","value":"","remark":""}'
,
call_dev_kyc
bigint
comment
'{"chs_name":"拨打电话线索设备数-kyc","description":"","etl":"","value":"","remark":""}'
,
call_dev_kyc
bigint
comment
'{"chs_name":"当天拨打电话线索设备数-kyc","description":"","etl":"","value":"","remark":""}'
,
call_num_kyc
bigint
comment
'{"chs_name":"拨打电话线索人次-kyc","description":"","etl":"","value":"","remark":""}'
,
call_num_kyc
bigint
comment
'{"chs_name":"当天拨打电话线索人次-kyc","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev_kyc
bigint
comment
'{"chs_name":"有效电话线索设备数-kyc","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev_kyc
bigint
comment
'{"chs_name":"当天有效电话线索设备数-kyc","description":"","etl":"","value":"","remark":""}'
,
valid_call_num_kyc
bigint
comment
'{"chs_name":"有效电话线索人次-kyc","description":"","etl":"","value":"","remark":""}'
,
valid_call_num_kyc
bigint
comment
'{"chs_name":"当天有效电话线索人次-kyc","description":"","etl":"","value":"","remark":""}'
,
call_dev_kyc_d
bigint
comment
'{"chs_name":"非当天拨打电话线索设备数-kyc","description":"","etl":"","value":"","remark":""}'
,
call_num_kyc_d
bigint
comment
'{"chs_name":"非当天拨打电话线索人次-kyc","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev_kyc_d
bigint
comment
'{"chs_name":"非当天有效电话线索设备数-kyc","description":"","etl":"","value":"","remark":""}'
,
valid_call_num_kyc_d
bigint
comment
'{"chs_name":"非当天有效电话线索人次-kyc","description":"","etl":"","value":"","remark":""}'
,
msg_dev_qa
bigint
comment
'{"chs_name":"私信咨询设备数-需求自测","description":"","etl":"","value":"","remark":""}'
,
msg_dev_qa
bigint
comment
'{"chs_name":"私信咨询设备数-需求自测","description":"","etl":"","value":"","remark":""}'
,
msg_num_qa
bigint
comment
'{"chs_name":"私信咨询人次-需求自测","description":"","etl":"","value":"","remark":""}'
,
msg_num_qa
bigint
comment
'{"chs_name":"私信咨询人次-需求自测","description":"","etl":"","value":"","remark":""}'
,
...
@@ -61,11 +73,14 @@ CREATE TABLE IF NOT EXISTS pm.tl_pm_userclue_d
...
@@ -61,11 +73,14 @@ CREATE TABLE IF NOT EXISTS pm.tl_pm_userclue_d
valid_msg_num_qa
bigint
comment
'{"chs_name":"有效私信咨询人次-需求自测","description":"","etl":"","value":"","remark":""}'
,
valid_msg_num_qa
bigint
comment
'{"chs_name":"有效私信咨询人次-需求自测","description":"","etl":"","value":"","remark":""}'
,
clue_dev_qa
bigint
comment
'{"chs_name":"授权电话线索设备数-需求自测","description":"","etl":"","value":"","remark":""}'
,
clue_dev_qa
bigint
comment
'{"chs_name":"授权电话线索设备数-需求自测","description":"","etl":"","value":"","remark":""}'
,
clue_num_qa
bigint
comment
'{"chs_name":"授权电话线索人次-需求自测","description":"","etl":"","value":"","remark":""}'
,
clue_num_qa
bigint
comment
'{"chs_name":"授权电话线索人次-需求自测","description":"","etl":"","value":"","remark":""}'
,
call_dev_qa
bigint
comment
'{"chs_name":"拨打电话线索设备数-需求自测","description":"","etl":"","value":"","remark":""}'
,
call_dev_qa
bigint
comment
'{"chs_name":"当天拨打电话线索设备数-需求自测","description":"","etl":"","value":"","remark":""}'
,
call_num_qa
bigint
comment
'{"chs_name":"拨打电话线索人次-需求自测","description":"","etl":"","value":"","remark":""}'
,
call_num_qa
bigint
comment
'{"chs_name":"当天拨打电话线索人次-需求自测","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev_qa
bigint
comment
'{"chs_name":"有效电话线索设备数-需求自测","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev_qa
bigint
comment
'{"chs_name":"当天有效电话线索设备数-需求自测","description":"","etl":"","value":"","remark":""}'
,
valid_call_num_qa
bigint
comment
'{"chs_name":"有效电话线索人次-需求自测","description":"","etl":"","value":"","remark":""}'
valid_call_num_qa
bigint
comment
'{"chs_name":"当天有效电话线索人次-需求自测","description":"","etl":"","value":"","remark":""}'
,
call_dev_qa_d
bigint
comment
'{"chs_name":"非当天拨打电话线索设备数-需求自测","description":"","etl":"","value":"","remark":""}'
,
call_num_qa_d
bigint
comment
'{"chs_name":"非当天拨打电话线索人次-需求自测","description":"","etl":"","value":"","remark":""}'
,
valid_call_dev_qa_d
bigint
comment
'{"chs_name":"非当天有效电话线索设备数-需求自测","description":"","etl":"","value":"","remark":""}'
,
valid_call_num_qa_d
bigint
comment
'{"chs_name":"非当天有效电话线索人次-需求自测","description":"","etl":"","value":"","remark":""}'
)
comment
'用户侧线索日报'
)
comment
'用户侧线索日报'
PARTITIONED
BY
(
PARTITION_DAY
STRING
comment
'分区日期'
)
PARTITIONED
BY
(
PARTITION_DAY
STRING
comment
'分区日期'
)
ROW
FORMAT
DELIMITED
ROW
FORMAT
DELIMITED
...
...
pm/clue_daily/report/clue_daily.sql
View file @
a371d573
...
@@ -10,21 +10,29 @@ SELECT day_id `日期`
...
@@ -10,21 +10,29 @@ SELECT day_id `日期`
,
valid_msg_num
as
`有效私信咨询人次-总计`
,
valid_msg_num
as
`有效私信咨询人次-总计`
,
clue_dev
as
`授权电话线索设备数-总计`
,
clue_dev
as
`授权电话线索设备数-总计`
,
clue_num
as
`授权电话线索人次-总计`
,
clue_num
as
`授权电话线索人次-总计`
,
call_dev
as
`拨打电话线索设备数-总计`
,
call_dev
+
call_dev_d
as
`拨打电话线索设备数-总计`
,
call_num
as
`拨打电话线索人次-总计`
,
call_num
+
call_num_d
as
`拨打电话线索人次-总计`
,
valid_call_dev
as
`有效电话线索设备数-总计`
,
valid_call_dev
+
valid_call_dev_d
as
`有效电话线索设备数-总计`
,
valid_call_num
as
`有效电话线索人次-总计`
,
valid_call_num
+
valid_call_num_d
as
`有效电话线索人次-总计`
,
call_dev
as
`当天拨打电话线索设备数-总计`
,
call_num
as
`当天拨打电话线索人次-总计`
,
valid_call_dev
as
`当天有效电话线索设备数-总计`
,
valid_call_num
as
`当天有效电话线索人次-总计`
,
msg_dev_4
`私信咨询设备数-3级以上商户`
,
msg_dev_3
`私信咨询设备数-3级以上商户`
,
msg_num_4
`私信咨询人次-3级以上商户`
,
msg_num_3
`私信咨询人次-3级以上商户`
,
valid_msg_dev_4
`有效私信咨询设备数-3级以上商户`
,
valid_msg_dev_3
`有效私信咨询设备数-3级以上商户`
,
valid_msg_num_4
as
`有效私信咨询人次-3级以上商户`
,
valid_msg_num_3
as
`有效私信咨询人次-3级以上商户`
,
clue_dev_4
as
`授权电话线索设备数-3级以上商户`
,
clue_dev_3
as
`授权电话线索设备数-3级以上商户`
,
clue_num_4
as
`授权电话线索人次-3级以上商户`
,
clue_num_3
as
`授权电话线索人次-3级以上商户`
,
call_dev_4
as
`拨打电话线索设备数-3级以上商户`
,
call_dev_3
+
call_dev_3_d
as
`拨打电话线索设备数-3级以上商户`
,
call_num_4
as
`拨打电话线索人次-3级以上商户`
,
call_num_3
+
valid_call_num_3
as
`拨打电话线索人次-3级以上商户`
,
valid_call_dev_4
as
`有效电话线索设备数-3级以上商户`
,
valid_call_dev_3
+
valid_call_dev_3_d
as
`有效电话线索设备数-3级以上商户`
,
valid_call_num_4
as
`有效电话线索人次-3级以上商户`
,
valid_call_num_3
+
valid_call_num_3_d
as
`有效电话线索人次-3级以上商户`
,
call_dev_3
as
`当天拨打电话线索设备数-3级以上商户`
,
call_num_3
as
`当天拨打电话线索人次-3级以上商户`
,
valid_call_dev_3
as
`当天有效电话线索设备数-3级以上商户`
,
valid_call_num_3
as
`当天有效电话线索人次-3级以上商户`
,
msg_dev_kyc
`私信咨询设备数-kyc`
,
msg_dev_kyc
`私信咨询设备数-kyc`
,
msg_num_kyc
`私信咨询人次-kyc`
,
msg_num_kyc
`私信咨询人次-kyc`
...
@@ -32,10 +40,14 @@ SELECT day_id `日期`
...
@@ -32,10 +40,14 @@ SELECT day_id `日期`
,
valid_msg_num_kyc
as
`有效私信咨询人次-kyc`
,
valid_msg_num_kyc
as
`有效私信咨询人次-kyc`
,
clue_dev_kyc
as
`授权电话线索设备数-kyc`
,
clue_dev_kyc
as
`授权电话线索设备数-kyc`
,
clue_num_kyc
as
`授权电话线索人次-kyc`
,
clue_num_kyc
as
`授权电话线索人次-kyc`
,
call_dev_kyc
as
`拨打电话线索设备数-kyc`
,
call_dev_kyc
+
call_dev_kyc_d
as
`拨打电话线索设备数-kyc`
,
call_num_kyc
as
`拨打电话线索人次-kyc`
,
call_num_kyc
+
call_num_kyc_d
as
`拨打电话线索人次-kyc`
,
valid_call_dev_kyc
as
`有效电话线索设备数-kyc`
,
valid_call_dev_kyc
+
valid_call_dev_kyc_d
as
`有效电话线索设备数-kyc`
,
valid_call_num_kyc
as
`有效电话线索人次-kyc`
,
valid_call_num_kyc
+
valid_call_num_kyc_d
as
`有效电话线索人次-kyc`
,
call_dev_kyc
as
`当天拨打电话线索设备数-kyc`
,
call_num_kyc
as
`当天拨打电话线索人次-kyc`
,
valid_call_dev_kyc
as
`当天有效电话线索设备数-kyc`
,
valid_call_num_kyc
as
`当天有效电话线索人次-kyc`
,
msg_dev_qa
`私信咨询设备数-需求自测`
,
msg_dev_qa
`私信咨询设备数-需求自测`
,
msg_num_qa
`私信咨询人次-需求自测`
,
msg_num_qa
`私信咨询人次-需求自测`
...
@@ -43,10 +55,14 @@ SELECT day_id `日期`
...
@@ -43,10 +55,14 @@ SELECT day_id `日期`
,
valid_msg_num_qa
as
`有效私信咨询人次-需求自测`
,
valid_msg_num_qa
as
`有效私信咨询人次-需求自测`
,
clue_dev_qa
as
`授权电话线索设备数-需求自测`
,
clue_dev_qa
as
`授权电话线索设备数-需求自测`
,
clue_num_qa
as
`授权电话线索人次-需求自测`
,
clue_num_qa
as
`授权电话线索人次-需求自测`
,
call_dev_qa
as
`拨打电话线索设备数-需求自测`
,
call_dev_qa
+
call_dev_qa_d
as
`拨打电话线索设备数-需求自测`
,
call_num_qa
as
`拨打电话线索人次-需求自测`
,
call_num_qa
+
call_num_qa_d
as
`拨打电话线索人次-需求自测`
,
valid_call_dev_qa
as
`有效电话线索设备数-需求自测`
,
valid_call_dev_qa
+
valid_call_dev_qa_d
as
`有效电话线索设备数-需求自测`
,
valid_call_num_qa
as
`有效电话线索人次-需求自测`
,
valid_call_num_qa
+
valid_call_num_qa_d
as
`有效电话线索人次-需求自测`
,
call_dev_qa_d
as
`当天拨打电话线索设备数-需求自测`
,
call_num_qa_d
as
`当天拨打电话线索人次-需求自测`
,
valid_call_dev_qa_d
as
`当天有效电话线索设备数-需求自测`
,
valid_call_num_qa_d
as
`当天有效电话线索人次-需求自测`
FROM
pm
.
tl_pm_userclue_d
FROM
pm
.
tl_pm_userclue_d
where
partition_day
in
(
'20200901'
,
'202001001'
,
'20201101'
,
'20201201'
,
'20210101'
,
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
))
where
partition_day
in
(
'20200901'
,
'202001001'
,
'20201101'
,
'20201201'
,
'20210101'
,
regexp_replace
(
date_sub
(
current_date
,
1
),
'-'
,
''
))
order
by
`日期`
,
`系统`
,
`新老`
,
`是否灰度`
order
by
`日期`
,
`系统`
,
`新老`
,
`是否灰度`
pm/meigou_detail_page/report/meigou_detail_page_dispense_pv.sql
View file @
a371d573
...
@@ -41,7 +41,7 @@ FROM
...
@@ -41,7 +41,7 @@ FROM
SELECT
t1
.
partition_date
as
`日期`
SELECT
t1
.
partition_date
as
`日期`
,
t1
.
device_type
as
`设备类型`
,
t1
.
device_type
as
`设备类型`
,
t1
.
active_type
as
`活跃类型`
,
t1
.
active_type
as
`活跃类型`
,
t
2
.
channel
as
`渠道`
,
t
1
.
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`
...
@@ -71,6 +71,7 @@ FROM
...
@@ -71,6 +71,7 @@ FROM
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
AND
page_name
=
'welfare_detail'
AND
action
=
'page_view'
AND
action
=
'page_view'
and
params
[
'is_first'
]
=
1
)
pv
)
pv
LEFT
JOIN
LEFT
JOIN
(
-- 去掉疑似机构刷量的PV和UV
(
-- 去掉疑似机构刷量的PV和UV
...
@@ -265,28 +266,35 @@ FROM
...
@@ -265,28 +266,35 @@ FROM
)
click
)
click
JOIN
JOIN
(
(
SELECT
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
select
partition_date
,
device_type
,
device_id
,
active_type
,
t
.
channel
,
case
WHEN
active_type
=
'4'
THEN
'老活跃设备'
from
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
select
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
or
first_channel_source_type
in
(
'promotion_aisi'
,
'promotion_koomobi_km00'
,
'promotion_koomobi_km01'
)
,
case
when
active_type
=
'4'
then
'老活跃设备'
or
first_channel_source_type
like
'%longyuzhixing%'
or
first_channel_source_type
like
'%jingmeng%'
when
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
end
as
active_type
or
first_channel_source_type
like
'%mailuo%'
THEN
'可疑'
,
array
(
case
when
(
a
.
device_id
is
not
null
or
b
.
device_id
is
not
null
WHEN
(
partition_date
>=
'20190601'
and
tmp
.
col2
=
'AI'
)
or
first_channel_source_type
like
'%xinyouxingkong%'
or
(
partition_date
<
'20200301'
AND
partition_date
>=
'20190601'
and
first_channel_source_type
like
'promotion_toutiao_jy%'
)
or
first_channel_source_type
like
'%jingmeng%'
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%'
)))
or
first_channel_source_type
like
'%longyuzhixing%'
THEN
'AI'
ELSE
'其他'
END
,
'合计'
)
as
channel
or
first_channel_source_type
like
'%mailuo%'
)
then
'渠道可疑'
FROM
online
.
ml_device_day_active_status
m
when
tmp
.
is_ai_channel
=
'true'
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:标识
(
select
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
pm
.
tl_pm_ydl
from
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
col3
=
'0204_danlei_channel'
)
tmp
where
partition_day
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
and
partition_day
<
regexp_replace
((
current_date
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
co
l1
on
first_channel_source_type
=
tmp
.
co
de
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
LEFT
JOIN
(
SELECT
DISTINCT
device_id
(
select
distinct
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
from
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
ON
m
.
device_id
=
a
.
device_id
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
select
device_id
,
day_id
from
pm
.
tl_pm_channel_d
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
...
@@ -298,12 +306,13 @@ FROM
...
@@ -298,12 +306,13 @@ FROM
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
)
a
LATERAL
VIEW
explode
(
a
.
channel
)
t
AS
channel
)
mas
)
mas
ON
click
.
cl_id
=
mas
.
device_id
ON
click
.
cl_id
=
mas
.
device_id
AND
click
.
partition_date
=
mas
.
partition_date
AND
click
.
partition_date
=
mas
.
partition_date
)
t1
)
t1
LATERAL
VIEW
explode
(
t1
.
channel
)
t2
AS
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t2
.
channel
)
T1
)
T1
ORDER
BY
`日期`
desc
,
`设备类型`
,
`活跃类型`
,
`渠道`
ORDER
BY
`日期`
desc
,
`设备类型`
,
`活跃类型`
,
`渠道`
pm/meigou_detail_page/report/meigou_detail_page_dispense_uv.sql
View file @
a371d573
--美购详情页的分发
--美购详情页的分发
SELECT
`日期`
,
`设备类型`
,
`活跃类型`
,
`渠道`
select
`日期`
,
`设备类型`
,
`活跃类型`
,
`渠道`
,
`美购详情页浏览uv`
,
`美购详情页浏览uv`
,(
`加购物车点击uv`
+
`评价列表页点击uv`
+
`立即支付点击uv`
+
`私信及电话咨询uv`
+
`选择美购项目点击uv`
,(
`加购物车点击uv`
+
`评价列表页点击uv`
+
`立即支付点击uv`
+
`私信及电话咨询uv`
+
`选择美购项目点击uv`
+
`机构主页点击uv`
+
`机构的其他美购点击uv`
+
`推荐美购点击uv`
+
`收藏点击uv`
+
`机构主页点击uv`
+
`机构的其他美购点击uv`
+
`推荐美购点击uv`
+
`收藏点击uv`
...
@@ -36,10 +36,10 @@ SELECT `日期`,`设备类型`,`活跃类型`,`渠道`
...
@@ -36,10 +36,10 @@ SELECT `日期`,`设备类型`,`活跃类型`,`渠道`
FROM
FROM
(
(
SELECT
t1
.
partition_date
as
`日期`
select
t1
.
partition_date
as
`日期`
,
t1
.
device_type
as
`设备类型`
,
t1
.
device_type
as
`设备类型`
,
t1
.
active_type
as
`活跃类型`
,
t1
.
active_type
as
`活跃类型`
,
t
2
.
channel
as
`渠道`
,
t
1
.
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`
...
@@ -57,234 +57,242 @@ FROM
...
@@ -57,234 +57,242 @@ FROM
FROM
FROM
(
(
SELECT
click
.
partition_date
,
click
.
cl_id
,
click
.
type
,
mas
.
active_type
,
mas
.
device_type
,
mas
.
channel
select
click
.
partition_date
,
click
.
cl_id
,
click
.
type
,
mas
.
active_type
,
mas
.
device_type
,
mas
.
channel
FROM
from
(
--浏览需要去掉疑似机构刷量的设备
(
--浏览需要去掉疑似机构刷量的设备
SELECT
uv
.
partition_date
as
partition_date
,
uv
.
cl_id
as
cl_id
,
type
select
uv
.
partition_date
as
partition_date
,
uv
.
cl_id
as
cl_id
,
type
FROM
from
(
(
SELECT
partition_date
,
cl_id
,
'美购详情页'
as
type
select
partition_date
,
cl_id
,
'美购详情页'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'page_view'
and
action
=
'page_view'
and
params
[
'is_first'
]
=
1
)
uv
)
uv
LEFT
JOIN
left
join
(
-- 去掉疑似机构刷量的UV和UV
(
-- 去掉疑似机构刷量的UV和UV
SELECT
distinct
device_id
select
distinct
device_id
FROM
ml
.
ml_d_ct_dv_devicespam_d
from
ml
.
ml_d_ct_dv_devicespam_d
WHERE
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
)
spam_pv
)
spam_pv
on
uv
.
cl_id
=
spam_pv
.
device_id
on
uv
.
cl_id
=
spam_pv
.
device_id
WHERE
spam_pv
.
device_id
IS
NULL
where
spam_pv
.
device_id
is
null
UNION
ALL
union
all
SELECT
partition_date
,
cl_id
,
'加购物车'
as
type
select
partition_date
,
cl_id
,
'加购物车'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'welfare_multiattribute_click_add'
and
action
=
'welfare_multiattribute_click_add'
UNION
ALL
union
all
SELECT
partition_date
,
cl_id
,
'右上角购物车'
as
type
select
partition_date
,
cl_id
,
'右上角购物车'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'on_click_navbar_cart'
and
action
=
'on_click_navbar_cart'
UNION
ALL
union
all
--点击查看更多评论
--点击查看更多评论
SELECT
partition_date
,
cl_id
,
'评价列表页'
as
type
select
partition_date
,
cl_id
,
'评价列表页'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
--AND page_name = 'welfare_detail'
--AND page_name = 'welfare_detail'
AND
action
=
'welfare_detail_click_comment'
and
action
=
'welfare_detail_click_comment'
UNION
ALL
union
all
--点击外显的评价标签
--点击外显的评价标签
SELECT
partition_date
,
cl_id
,
'评价列表页'
as
type
select
partition_date
,
cl_id
,
'评价列表页'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'service_comment_click_tag'
and
action
=
'service_comment_click_tag'
UNION
ALL
union
all
--点击外显的日记卡片
--点击外显的日记卡片
SELECT
partition_date
,
cl_id
,
'评价列表页'
as
type
select
partition_date
,
cl_id
,
'评价列表页'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'welfare_detail_comment_click_diary_card'
and
action
=
'welfare_detail_comment_click_diary_card'
UNION
ALL
union
all
SELECT
partition_date
,
cl_id
,
'立即支付'
as
type
select
partition_date
,
cl_id
,
'立即支付'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'welfare_multiattribute_click_buy'
and
action
=
'welfare_multiattribute_click_buy'
UNION
ALL
union
all
--点击选择更美项目
--点击选择更美项目
SELECT
partition_date
,
cl_id
,
'选择美购项目'
as
type
select
partition_date
,
cl_id
,
'选择美购项目'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'on_click_button'
and
action
=
'on_click_button'
AND
params
[
'button_name'
]
=
'sku_choose'
and
params
[
'button_name'
]
=
'sku_choose'
UNION
ALL
union
all
--7.22新版本--点击外露的美购项目
--7.22新版本--点击外露的美购项目
SELECT
partition_date
,
cl_id
,
'选择美购项目'
as
type
select
partition_date
,
cl_id
,
'选择美购项目'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'on_click_button'
and
action
=
'on_click_button'
AND
params
[
'button_name'
]
=
'service_sku'
and
params
[
'button_name'
]
=
'service_sku'
UNION
ALL
union
all
--7.22新版本--点击查看更多
--7.22新版本--点击查看更多
SELECT
partition_date
,
cl_id
,
'选择美购项目'
as
type
select
partition_date
,
cl_id
,
'选择美购项目'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'on_click_button'
and
action
=
'on_click_button'
AND
params
[
'button_name'
]
=
'sku_all'
and
params
[
'button_name'
]
=
'sku_all'
UNION
ALL
union
all
--点击私信按钮
--点击私信按钮
SELECT
partition_date
,
cl_id
,
'私信及电话咨询'
as
type
select
partition_date
,
cl_id
,
'私信及电话咨询'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
--AND page_name = 'welfare_detail'
--AND page_name = 'welfare_detail'
AND
action
=
'welfare_detail_click_message'
and
action
=
'welfare_detail_click_message'
UNION
ALL
union
all
--7.20之后灰度上线的快捷咨询按钮和预约面诊按钮
--7.20之后灰度上线的快捷咨询按钮和预约面诊按钮
SELECT
partition_date
,
cl_id
,
'私信及电话咨询'
as
type
select
partition_date
,
cl_id
,
'私信及电话咨询'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'on_click_button'
and
action
=
'on_click_button'
AND
params
[
'button_name'
]
in
(
'question_tag'
,
'appointment'
)
and
params
[
'button_name'
]
in
(
'question_tag'
,
'appointment'
)
UNION
ALL
union
all
--点击机构下面的在线咨询和电话咨询
--点击机构下面的在线咨询和电话咨询
SELECT
partition_date
,
cl_id
,
'私信及电话咨询'
as
type
select
partition_date
,
cl_id
,
'私信及电话咨询'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
--AND page_name = 'welfare_detail'
--AND page_name = 'welfare_detail'
AND
action
=
'welfare_detail_click_curearea_contact'
and
action
=
'welfare_detail_click_curearea_contact'
AND
params
[
'connect_type'
]
in
(
'onlineconsult'
,
'phone'
)
and
params
[
'connect_type'
]
in
(
'onlineconsult'
,
'phone'
)
UNION
ALL
union
all
SELECT
partition_date
,
cl_id
,
'机构主页'
as
type
select
partition_date
,
cl_id
,
'机构主页'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
--AND page_name = 'welfare_detail'
--AND page_name = 'welfare_detail'
AND
action
=
'welfare_detail_click_curearea'
and
action
=
'welfare_detail_click_curearea'
AND
params
[
'cure_type'
]
=
'organization'
and
params
[
'cure_type'
]
=
'organization'
UNION
ALL
union
all
SELECT
partition_date
,
cl_id
,
'机构的其他美购'
as
type
select
partition_date
,
cl_id
,
'机构的其他美购'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
--AND page_name = 'welfare_detail'
--AND page_name = 'welfare_detail'
AND
action
=
'welfare_detail_click_seller_service_item'
and
action
=
'welfare_detail_click_seller_service_item'
UNION
ALL
union
all
SELECT
partition_date
,
cl_id
,
'机构导航'
as
type
select
partition_date
,
cl_id
,
'机构导航'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
--AND page_name = 'welfare_detail'
--AND page_name = 'welfare_detail'
AND
action
=
'welfare_detail_click_address'
and
action
=
'welfare_detail_click_address'
UNION
ALL
union
all
SELECT
partition_date
,
cl_id
,
'推荐美购'
as
type
select
partition_date
,
cl_id
,
'推荐美购'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'on_click_card'
and
action
=
'on_click_card'
AND
params
[
'card_content_type'
]
=
'service'
and
params
[
'card_content_type'
]
=
'service'
AND
params
[
'tab_name'
]
=
'推荐'
and
params
[
'tab_name'
]
=
'推荐'
UNION
ALL
union
all
SELECT
partition_date
,
cl_id
,
'收藏'
as
type
select
partition_date
,
cl_id
,
'收藏'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'on_click_favor'
and
action
=
'on_click_favor'
AND
params
[
'favor_type'
]
=
'service'
and
params
[
'favor_type'
]
=
'service'
AND
params
[
'motion'
]
=
'do'
and
params
[
'motion'
]
=
'do'
UNION
ALL
union
all
SELECT
partition_date
,
cl_id
,
'医生主页'
as
type
select
partition_date
,
cl_id
,
'医生主页'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
--AND page_name = 'welfare_detail'
--AND page_name = 'welfare_detail'
AND
action
=
'welfare_detail_click_curearea'
and
action
=
'welfare_detail_click_curearea'
AND
params
[
'cure_type'
]
=
'doctor'
and
params
[
'cure_type'
]
=
'doctor'
UNION
ALL
union
all
SELECT
partition_date
,
cl_id
,
'分享'
as
type
select
partition_date
,
cl_id
,
'分享'
as
type
FROM
online
.
bl_hdfs_maidian_updates
from
online
.
bl_hdfs_maidian_updates
WHERE
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
and
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
and
page_name
=
'welfare_detail'
AND
action
=
'page_click_share'
and
action
=
'page_click_share'
)
click
)
click
JOIN
join
(
(
SELECT
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
select
partition_date
,
device_type
,
device_id
,
active_type
,
t
.
channel
,
case
WHEN
active_type
=
'4'
THEN
'老活跃设备'
from
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
select
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
or
first_channel_source_type
in
(
'promotion_aisi'
,
'promotion_koomobi_km00'
,
'promotion_koomobi_km01'
)
,
case
when
active_type
=
'4'
then
'老活跃设备'
or
first_channel_source_type
like
'%longyuzhixing%'
or
first_channel_source_type
like
'%jingmeng%'
when
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
end
as
active_type
or
first_channel_source_type
like
'%mailuo%'
THEN
'可疑'
,
array
(
case
when
(
a
.
device_id
is
not
null
or
b
.
device_id
is
not
null
WHEN
(
partition_date
>=
'20190601'
and
tmp
.
col2
=
'AI'
)
or
first_channel_source_type
like
'%xinyouxingkong%'
or
(
partition_date
<
'20200301'
AND
partition_date
>=
'20190601'
and
first_channel_source_type
like
'promotion_toutiao_jy%'
)
or
first_channel_source_type
like
'%jingmeng%'
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%'
)))
or
first_channel_source_type
like
'%longyuzhixing%'
THEN
'AI'
ELSE
'其他'
END
,
'合计'
)
as
channel
or
first_channel_source_type
like
'%mailuo%'
)
then
'渠道可疑'
FROM
online
.
ml_device_day_active_status
m
when
tmp
.
is_ai_channel
=
'true'
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:标识
(
select
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
pm
.
tl_pm_ydl
from
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
col3
=
'0204_danlei_channel'
)
tmp
where
partition_day
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
and
partition_day
<
regexp_replace
((
current_date
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
co
l1
on
first_channel_source_type
=
tmp
.
co
de
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
LEFT
JOIN
(
SELECT
DISTINCT
device_id
(
select
distinct
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
from
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
ON
m
.
device_id
=
a
.
device_id
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
select
device_id
,
day_id
from
pm
.
tl_pm_channel_d
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
...
@@ -296,12 +304,13 @@ FROM
...
@@ -296,12 +304,13 @@ FROM
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
)
a
LATERAL
VIEW
explode
(
a
.
channel
)
t
AS
channel
)
mas
)
mas
ON
click
.
cl_id
=
mas
.
device_id
ON
click
.
cl_id
=
mas
.
device_id
AND
click
.
partition_date
=
mas
.
partition_date
AND
click
.
partition_date
=
mas
.
partition_date
)
t1
)
t1
LATERAL
VIEW
explode
(
t1
.
channel
)
t2
AS
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t2
.
channel
)
T1
)
T1
ORDER
BY
`日期`
desc
,
`设备类型`
,
`活跃类型`
,
`渠道`
ORDER
BY
`日期`
desc
,
`设备类型`
,
`活跃类型`
,
`渠道`
pm/meigou_detail_page/report/meigou_detail_page_source_pv.sql
View file @
a371d573
...
@@ -31,16 +31,16 @@ SELECT T1.partition_date as `日期`
...
@@ -31,16 +31,16 @@ SELECT T1.partition_date as `日期`
,
concat
(
round
(
T3
.
org_add_pv
/
T2
.
organization_detail_pv
*
100
,
2
),
'%'
)
as
`医院主页-点击加车率`
,
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_buy_pv
/
T2
.
organization_detail_pv
*
100
,
2
),
'%'
)
as
`医院主页-点击立即支付率`
,
concat
(
round
(
T3
.
org_msg_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`
,
T1
.
category_pv
as
`
1级
品类聚合页pv`
,
T2
.
category_pv
as
`品类聚合页-转化pv`
,
T2
.
category_pv
as
`
1级
品类聚合页-转化pv`
,
T3
.
category_add_pv
as
`品类聚合页-转化点击加车pv`
,
T3
.
category_add_pv
as
`
1级
品类聚合页-转化点击加车pv`
,
T3
.
category_buy_pv
as
`品类聚合页-转化点击立即支付pv`
,
T3
.
category_buy_pv
as
`
1级
品类聚合页-转化点击立即支付pv`
,
T3
.
category_msg_pv
as
`品类聚合页-转化点击私信咨询pv`
,
T3
.
category_msg_pv
as
`
1级
品类聚合页-转化点击私信咨询pv`
,
concat
(
round
(
T2
.
category_pv
/
T1
.
category_pv
*
100
,
2
),
'%'
)
as
`品类聚合页-转化pv率`
,
concat
(
round
(
T2
.
category_pv
/
T1
.
category_pv
*
100
,
2
),
'%'
)
as
`
1级
品类聚合页-转化pv率`
,
concat
(
round
(
T2
.
category_pv
/
T1
.
wel_pv
*
100
,
2
),
'%'
)
as
`品类聚合页-转化美购pv占比`
,
concat
(
round
(
T2
.
category_pv
/
T1
.
wel_pv
*
100
,
2
),
'%'
)
as
`
1级
品类聚合页-转化美购pv占比`
,
concat
(
round
(
T3
.
category_add_pv
/
T2
.
category_pv
*
100
,
2
),
'%'
)
as
`品类聚合页-点击加车率`
,
concat
(
round
(
T3
.
category_add_pv
/
T2
.
category_pv
*
100
,
2
),
'%'
)
as
`
1级
品类聚合页-点击加车率`
,
concat
(
round
(
T3
.
category_buy_pv
/
T2
.
category_pv
*
100
,
2
),
'%'
)
as
`品类聚合页-点击立即支付率`
,
concat
(
round
(
T3
.
category_buy_pv
/
T2
.
category_pv
*
100
,
2
),
'%'
)
as
`
1级
品类聚合页-点击立即支付率`
,
concat
(
round
(
T3
.
category_msg_pv
/
T2
.
category_pv
*
100
,
2
),
'%'
)
as
`品类聚合页-点击私信咨询率`
,
concat
(
round
(
T3
.
category_msg_pv
/
T2
.
category_pv
*
100
,
2
),
'%'
)
as
`
1级
品类聚合页-点击私信咨询率`
,
T1
.
conversation_detail_pv
as
`私信详情页pv`
,
T1
.
conversation_detail_pv
as
`私信详情页pv`
,
T2
.
conversation_detail_pv
as
`私信详情页-转化pv`
,
T2
.
conversation_detail_pv
as
`私信详情页-转化pv`
,
T3
.
conv_add_pv
as
`私信详情页-转化点击加车pv`
,
T3
.
conv_add_pv
as
`私信详情页-转化点击加车pv`
...
@@ -51,16 +51,16 @@ SELECT T1.partition_date as `日期`
...
@@ -51,16 +51,16 @@ SELECT T1.partition_date as `日期`
,
concat
(
round
(
T3
.
conv_add_pv
/
T2
.
conversation_detail_pv
*
100
,
2
),
'%'
)
as
`私信详情页-点击加车率`
,
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_buy_pv
/
T2
.
conversation_detail_pv
*
100
,
2
),
'%'
)
as
`私信详情页-点击立即支付率`
,
concat
(
round
(
T3
.
conv_msg_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`
,
T1
.
welfare_list_pv
as
`
2级品类聚合
页pv`
,
T2
.
welfare_list_pv
as
`
美购列表
页-转化pv`
,
T2
.
welfare_list_pv
as
`
2级品类聚合
页-转化pv`
,
T3
.
wel_list_add_pv
as
`
美购列表
页-转化点击加车pv`
,
T3
.
wel_list_add_pv
as
`
2级品类聚合
页-转化点击加车pv`
,
T3
.
wel_list_buy_pv
as
`
美购列表
页-转化点击立即支付pv`
,
T3
.
wel_list_buy_pv
as
`
2级品类聚合
页-转化点击立即支付pv`
,
T3
.
wel_list_msg_pv
as
`
美购列表
页-转化点击私信咨询pv`
,
T3
.
wel_list_msg_pv
as
`
2级品类聚合
页-转化点击私信咨询pv`
,
concat
(
round
(
T2
.
welfare_list_pv
/
T1
.
welfare_list_pv
*
100
,
2
),
'%'
)
as
`
美购列表
页-转化pv率`
,
concat
(
round
(
T2
.
welfare_list_pv
/
T1
.
welfare_list_pv
*
100
,
2
),
'%'
)
as
`
2级品类聚合
页-转化pv率`
,
concat
(
round
(
T2
.
welfare_list_pv
/
T1
.
wel_pv
*
100
,
2
),
'%'
)
as
`
美购列表
页-转化美购pv占比`
,
concat
(
round
(
T2
.
welfare_list_pv
/
T1
.
wel_pv
*
100
,
2
),
'%'
)
as
`
2级品类聚合
页-转化美购pv占比`
,
concat
(
round
(
T3
.
wel_list_add_pv
/
T2
.
welfare_list_pv
*
100
,
2
),
'%'
)
as
`
美购列表
页-点击加车率`
,
concat
(
round
(
T3
.
wel_list_add_pv
/
T2
.
welfare_list_pv
*
100
,
2
),
'%'
)
as
`
2级品类聚合
页-点击加车率`
,
concat
(
round
(
T3
.
wel_list_buy_pv
/
T2
.
welfare_list_pv
*
100
,
2
),
'%'
)
as
`
美购列表
页-点击立即支付率`
,
concat
(
round
(
T3
.
wel_list_buy_pv
/
T2
.
welfare_list_pv
*
100
,
2
),
'%'
)
as
`
2级品类聚合
页-点击立即支付率`
,
concat
(
round
(
T3
.
wel_list_msg_pv
/
T2
.
welfare_list_pv
*
100
,
2
),
'%'
)
as
`
美购列表
页-点击私信咨询率`
,
concat
(
round
(
T3
.
wel_list_msg_pv
/
T2
.
welfare_list_pv
*
100
,
2
),
'%'
)
as
`
2级品类聚合
页-点击私信咨询率`
,
T1
.
my_cart_pv
as
`购物车pv`
,
T1
.
my_cart_pv
as
`购物车pv`
,
T2
.
my_cart_pv
as
`购物车-转化pv`
,
T2
.
my_cart_pv
as
`购物车-转化pv`
,
T3
.
cart_add_pv
as
`购物车-转化点击加车pv`
,
T3
.
cart_add_pv
as
`购物车-转化点击加车pv`
...
@@ -177,7 +177,7 @@ FROM
...
@@ -177,7 +177,7 @@ FROM
SELECT
t1
.
partition_date
SELECT
t1
.
partition_date
,
t1
.
device_type
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
active_type
,
t
2
.
channel
,
t
1
.
channel
,
count
(
case
when
page_name
=
'welfare_detail'
then
t1
.
cl_id
end
)
as
wel_pv
,
count
(
case
when
page_name
=
'welfare_detail'
then
t1
.
cl_id
end
)
as
wel_pv
,
count
(
case
when
page_name
=
'search_result_more'
then
t1
.
cl_id
end
)
as
search_result_more_pv
,
count
(
case
when
page_name
=
'search_result_more'
then
t1
.
cl_id
end
)
as
search_result_more_pv
,
count
(
case
when
page_name
=
'search_result_welfare'
then
t1
.
cl_id
end
)
as
search_result_welfare_pv
,
count
(
case
when
page_name
=
'search_result_welfare'
then
t1
.
cl_id
end
)
as
search_result_welfare_pv
...
@@ -205,31 +205,39 @@ FROM
...
@@ -205,31 +205,39 @@ FROM
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
--AND page_name = 'welfare_detail'
--AND page_name = 'welfare_detail'
AND
action
=
'page_view'
AND
action
=
'page_view'
and
params
[
'is_first'
]
=
1
)
t1
)
t1
JOIN
JOIN
(
(
SELECT
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
select
partition_date
,
device_type
,
device_id
,
active_type
,
t
.
channel
,
case
WHEN
active_type
=
'4'
THEN
'老活跃设备'
from
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
select
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
or
first_channel_source_type
in
(
'promotion_aisi'
,
'promotion_koomobi_km00'
,
'promotion_koomobi_km01'
)
,
case
when
active_type
=
'4'
then
'老活跃设备'
or
first_channel_source_type
like
'%longyuzhixing%'
or
first_channel_source_type
like
'%jingmeng%'
when
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
end
as
active_type
or
first_channel_source_type
like
'%mailuo%'
THEN
'可疑'
,
array
(
case
when
(
a
.
device_id
is
not
null
or
b
.
device_id
is
not
null
WHEN
(
partition_date
>=
'20190601'
and
tmp
.
col2
=
'AI'
)
or
first_channel_source_type
like
'%xinyouxingkong%'
or
(
partition_date
<
'20200301'
AND
partition_date
>=
'20190601'
and
first_channel_source_type
like
'promotion_toutiao_jy%'
)
or
first_channel_source_type
like
'%jingmeng%'
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%'
)))
or
first_channel_source_type
like
'%longyuzhixing%'
THEN
'AI'
ELSE
'其他'
END
,
'合计'
)
as
channel
or
first_channel_source_type
like
'%mailuo%'
)
then
'渠道可疑'
FROM
online
.
ml_device_day_active_status
m
when
tmp
.
is_ai_channel
=
'true'
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:标识
(
select
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
pm
.
tl_pm_ydl
from
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
col3
=
'0204_danlei_channel'
)
tmp
where
partition_day
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
and
partition_day
<
regexp_replace
((
current_date
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
col1
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
LEFT
JOIN
(
SELECT
DISTINCT
device_id
(
select
distinct
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
from
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
ON
m
.
device_id
=
a
.
device_id
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
select
device_id
,
day_id
from
pm
.
tl_pm_channel_d
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
...
@@ -241,6 +249,8 @@ FROM
...
@@ -241,6 +249,8 @@ FROM
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
)
a
LATERAL
VIEW
explode
(
a
.
channel
)
t
AS
channel
)
mas
)
mas
ON
t1
.
cl_id
=
mas
.
device_id
ON
t1
.
cl_id
=
mas
.
device_id
AND
t1
.
partition_date
=
mas
.
partition_date
AND
t1
.
partition_date
=
mas
.
partition_date
...
@@ -253,15 +263,14 @@ FROM
...
@@ -253,15 +263,14 @@ FROM
on
t1
.
cl_id
=
spam_pv
.
device_id
on
t1
.
cl_id
=
spam_pv
.
device_id
WHERE
spam_pv
.
device_id
IS
NULL
WHERE
spam_pv
.
device_id
IS
NULL
)
t1
)
t1
LATERAL
VIEW
explode
(
t1
.
channel
)
t2
AS
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t2
.
channel
)
T1
)
T1
LEFT
JOIN
LEFT
JOIN
(
--不同referrer下的美购详情页pv/uv
(
--不同referrer下的美购详情页pv/uv
SELECT
t1
.
partition_date
SELECT
t1
.
partition_date
,
t1
.
device_type
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
active_type
,
t
2
.
channel
,
t
1
.
channel
,
count
(
case
when
referrer
=
'welfare_detail'
then
t1
.
cl_id
end
)
as
wel_pv
,
count
(
case
when
referrer
=
'welfare_detail'
then
t1
.
cl_id
end
)
as
wel_pv
,
count
(
case
when
referrer
=
'search_result_more'
then
t1
.
cl_id
end
)
as
search_result_more_pv
,
count
(
case
when
referrer
=
'search_result_more'
then
t1
.
cl_id
end
)
as
search_result_more_pv
,
count
(
case
when
referrer
=
'search_result_welfare'
then
t1
.
cl_id
end
)
as
search_result_welfare_pv
,
count
(
case
when
referrer
=
'search_result_welfare'
then
t1
.
cl_id
end
)
as
search_result_welfare_pv
...
@@ -289,31 +298,39 @@ LEFT JOIN
...
@@ -289,31 +298,39 @@ LEFT JOIN
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
AND
page_name
=
'welfare_detail'
AND
action
=
'page_view'
AND
action
=
'page_view'
and
params
[
'is_first'
]
=
1
)
t1
)
t1
JOIN
JOIN
(
(
SELECT
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
select
partition_date
,
device_type
,
device_id
,
active_type
,
t
.
channel
,
case
WHEN
active_type
=
'4'
THEN
'老活跃设备'
from
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
select
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
or
first_channel_source_type
in
(
'promotion_aisi'
,
'promotion_koomobi_km00'
,
'promotion_koomobi_km01'
)
,
case
when
active_type
=
'4'
then
'老活跃设备'
or
first_channel_source_type
like
'%longyuzhixing%'
or
first_channel_source_type
like
'%jingmeng%'
when
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
end
as
active_type
or
first_channel_source_type
like
'%mailuo%'
THEN
'可疑'
,
array
(
case
when
(
a
.
device_id
is
not
null
or
b
.
device_id
is
not
null
WHEN
(
partition_date
>=
'20190601'
and
tmp
.
col2
=
'AI'
)
or
first_channel_source_type
like
'%xinyouxingkong%'
or
(
partition_date
<
'20200301'
AND
partition_date
>=
'20190601'
and
first_channel_source_type
like
'promotion_toutiao_jy%'
)
or
first_channel_source_type
like
'%jingmeng%'
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%'
)))
or
first_channel_source_type
like
'%longyuzhixing%'
THEN
'AI'
ELSE
'其他'
END
,
'合计'
)
as
channel
or
first_channel_source_type
like
'%mailuo%'
)
then
'渠道可疑'
FROM
online
.
ml_device_day_active_status
m
when
tmp
.
is_ai_channel
=
'true'
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:标识
(
select
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
pm
.
tl_pm_ydl
from
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
col3
=
'0204_danlei_channel'
)
tmp
where
partition_day
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
and
partition_day
<
regexp_replace
((
current_date
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
col1
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
LEFT
JOIN
(
SELECT
DISTINCT
device_id
(
select
distinct
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
from
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
ON
m
.
device_id
=
a
.
device_id
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
select
device_id
,
day_id
from
pm
.
tl_pm_channel_d
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
...
@@ -325,6 +342,8 @@ LEFT JOIN
...
@@ -325,6 +342,8 @@ LEFT JOIN
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
)
a
LATERAL
VIEW
explode
(
a
.
channel
)
t
AS
channel
)
mas
)
mas
ON
t1
.
cl_id
=
mas
.
device_id
ON
t1
.
cl_id
=
mas
.
device_id
AND
t1
.
partition_date
=
mas
.
partition_date
AND
t1
.
partition_date
=
mas
.
partition_date
...
@@ -337,8 +356,7 @@ LEFT JOIN
...
@@ -337,8 +356,7 @@ LEFT JOIN
on
t1
.
cl_id
=
spam_pv
.
device_id
on
t1
.
cl_id
=
spam_pv
.
device_id
WHERE
spam_pv
.
device_id
IS
NULL
WHERE
spam_pv
.
device_id
IS
NULL
)
t1
)
t1
LATERAL
VIEW
explode
(
t1
.
channel
)
t2
AS
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t2
.
channel
)
T2
)
T2
ON
T1
.
partition_date
=
T2
.
partition_date
ON
T1
.
partition_date
=
T2
.
partition_date
and
T1
.
device_type
=
T2
.
device_type
and
T1
.
device_type
=
T2
.
device_type
...
@@ -349,7 +367,7 @@ LEFT JOIN
...
@@ -349,7 +367,7 @@ LEFT JOIN
SELECT
t1
.
partition_date
SELECT
t1
.
partition_date
,
t1
.
device_type
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
active_type
,
t
2
.
channel
,
t
1
.
channel
,
count
(
case
when
referrer
=
'welfare_detail'
and
action
=
'welfare_multiattribute_click_add'
then
t1
.
cl_id
end
)
as
wel_add_pv
,
count
(
case
when
referrer
=
'welfare_detail'
and
action
=
'welfare_multiattribute_click_add'
then
t1
.
cl_id
end
)
as
wel_add_pv
,
count
(
case
when
referrer
=
'welfare_detail'
and
action
=
'welfare_multiattribute_click_buy'
then
t1
.
cl_id
end
)
as
wel_buy_pv
,
count
(
case
when
referrer
=
'welfare_detail'
and
action
=
'welfare_multiattribute_click_buy'
then
t1
.
cl_id
end
)
as
wel_buy_pv
,
count
(
case
when
referrer
=
'welfare_detail'
and
action
in
(
'welfare_detail_click_message'
,
'on_click_button'
)
then
t1
.
cl_id
end
)
as
wel_msg_pv
,
count
(
case
when
referrer
=
'welfare_detail'
and
action
in
(
'welfare_detail_click_message'
,
'on_click_button'
)
then
t1
.
cl_id
end
)
as
wel_msg_pv
...
@@ -444,28 +462,35 @@ LEFT JOIN
...
@@ -444,28 +462,35 @@ LEFT JOIN
)
t1
)
t1
JOIN
JOIN
(
(
SELECT
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
select
partition_date
,
device_type
,
device_id
,
active_type
,
t
.
channel
,
case
WHEN
active_type
=
'4'
THEN
'老活跃设备'
from
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
select
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
or
first_channel_source_type
in
(
'promotion_aisi'
,
'promotion_koomobi_km00'
,
'promotion_koomobi_km01'
)
,
case
when
active_type
=
'4'
then
'老活跃设备'
or
first_channel_source_type
like
'%longyuzhixing%'
or
first_channel_source_type
like
'%jingmeng%'
when
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
end
as
active_type
or
first_channel_source_type
like
'%mailuo%'
THEN
'可疑'
,
array
(
case
when
(
a
.
device_id
is
not
null
or
b
.
device_id
is
not
null
WHEN
(
partition_date
>=
'20190601'
and
tmp
.
col2
=
'AI'
)
or
first_channel_source_type
like
'%xinyouxingkong%'
or
(
partition_date
<
'20200301'
AND
partition_date
>=
'20190601'
and
first_channel_source_type
like
'promotion_toutiao_jy%'
)
or
first_channel_source_type
like
'%jingmeng%'
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%'
)))
or
first_channel_source_type
like
'%longyuzhixing%'
THEN
'AI'
ELSE
'其他'
END
,
'合计'
)
as
channel
or
first_channel_source_type
like
'%mailuo%'
)
then
'渠道可疑'
FROM
online
.
ml_device_day_active_status
m
when
tmp
.
is_ai_channel
=
'true'
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:标识
(
select
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
pm
.
tl_pm_ydl
from
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
col3
=
'0204_danlei_channel'
)
tmp
where
partition_day
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
and
partition_day
<
regexp_replace
((
current_date
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
col1
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
LEFT
JOIN
(
SELECT
DISTINCT
device_id
(
select
distinct
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
from
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
ON
m
.
device_id
=
a
.
device_id
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
select
device_id
,
day_id
from
pm
.
tl_pm_channel_d
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
...
@@ -477,6 +502,8 @@ LEFT JOIN
...
@@ -477,6 +502,8 @@ LEFT JOIN
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
)
a
LATERAL
VIEW
explode
(
a
.
channel
)
t
AS
channel
)
mas
)
mas
ON
t1
.
cl_id
=
mas
.
device_id
ON
t1
.
cl_id
=
mas
.
device_id
AND
t1
.
partition_date
=
mas
.
partition_date
AND
t1
.
partition_date
=
mas
.
partition_date
...
@@ -489,8 +516,7 @@ LEFT JOIN
...
@@ -489,8 +516,7 @@ LEFT JOIN
on
t1
.
cl_id
=
spam_pv
.
device_id
on
t1
.
cl_id
=
spam_pv
.
device_id
WHERE
spam_pv
.
device_id
IS
NULL
WHERE
spam_pv
.
device_id
IS
NULL
)
t1
)
t1
LATERAL
VIEW
explode
(
t1
.
channel
)
t2
AS
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t2
.
channel
)
T3
)
T3
ON
T1
.
partition_date
=
T3
.
partition_date
ON
T1
.
partition_date
=
T3
.
partition_date
and
T1
.
device_type
=
T3
.
device_type
and
T1
.
device_type
=
T3
.
device_type
...
...
pm/meigou_detail_page/report/meigou_detail_page_source_uv.sql
View file @
a371d573
...
@@ -25,16 +25,16 @@ SELECT T1.partition_date as `日期`
...
@@ -25,16 +25,16 @@ SELECT T1.partition_date as `日期`
,
concat
(
round
(
T3
.
org_add_uv
/
T2
.
organization_detail_uv
*
100
,
2
),
'%'
)
as
`医院主页-点击加车率`
,
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_buy_uv
/
T2
.
organization_detail_uv
*
100
,
2
),
'%'
)
as
`医院主页-点击立即支付率`
,
concat
(
round
(
T3
.
org_msg_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`
,
T1
.
category_uv
as
`
1级
品类聚合页uv`
,
T2
.
category_uv
as
`品类聚合页-转化uv`
,
T2
.
category_uv
as
`
1级
品类聚合页-转化uv`
,
T3
.
category_add_uv
as
`品类聚合页-转化点击加车uv`
,
T3
.
category_add_uv
as
`
1级
品类聚合页-转化点击加车uv`
,
T3
.
category_buy_uv
as
`品类聚合页-转化点击立即支付uv`
,
T3
.
category_buy_uv
as
`
1级
品类聚合页-转化点击立即支付uv`
,
T3
.
category_msg_uv
as
`品类聚合页-转化点击私信咨询uv`
,
T3
.
category_msg_uv
as
`
1级
品类聚合页-转化点击私信咨询uv`
,
concat
(
round
(
T2
.
category_uv
/
T1
.
category_uv
*
100
,
2
),
'%'
)
as
`品类聚合页-转化uv率`
,
concat
(
round
(
T2
.
category_uv
/
T1
.
category_uv
*
100
,
2
),
'%'
)
as
`
1级
品类聚合页-转化uv率`
,
concat
(
round
(
T2
.
category_uv
/
T1
.
wel_uv
*
100
,
2
),
'%'
)
as
`品类聚合页-转化美购uv占比`
,
concat
(
round
(
T2
.
category_uv
/
T1
.
wel_uv
*
100
,
2
),
'%'
)
as
`
1级
品类聚合页-转化美购uv占比`
,
concat
(
round
(
T3
.
category_add_uv
/
T2
.
category_uv
*
100
,
2
),
'%'
)
as
`品类聚合页-点击加车率`
,
concat
(
round
(
T3
.
category_add_uv
/
T2
.
category_uv
*
100
,
2
),
'%'
)
as
`
1级
品类聚合页-点击加车率`
,
concat
(
round
(
T3
.
category_buy_uv
/
T2
.
category_uv
*
100
,
2
),
'%'
)
as
`品类聚合页-点击立即支付率`
,
concat
(
round
(
T3
.
category_buy_uv
/
T2
.
category_uv
*
100
,
2
),
'%'
)
as
`
1级
品类聚合页-点击立即支付率`
,
concat
(
round
(
T3
.
category_msg_uv
/
T2
.
category_uv
*
100
,
2
),
'%'
)
as
`品类聚合页-点击私信咨询率`
,
concat
(
round
(
T3
.
category_msg_uv
/
T2
.
category_uv
*
100
,
2
),
'%'
)
as
`
1级
品类聚合页-点击私信咨询率`
,
T1
.
conversation_detail_uv
as
`私信详情页uv`
,
T1
.
conversation_detail_uv
as
`私信详情页uv`
,
T2
.
conversation_detail_uv
as
`私信详情页-转化uv`
,
T2
.
conversation_detail_uv
as
`私信详情页-转化uv`
,
T3
.
conv_add_uv
as
`私信详情页-转化点击加车uv`
,
T3
.
conv_add_uv
as
`私信详情页-转化点击加车uv`
...
@@ -45,16 +45,16 @@ SELECT T1.partition_date as `日期`
...
@@ -45,16 +45,16 @@ SELECT T1.partition_date as `日期`
,
concat
(
round
(
T3
.
conv_add_uv
/
T2
.
conversation_detail_uv
*
100
,
2
),
'%'
)
as
`私信详情页-点击加车率`
,
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_buy_uv
/
T2
.
conversation_detail_uv
*
100
,
2
),
'%'
)
as
`私信详情页-点击立即支付率`
,
concat
(
round
(
T3
.
conv_msg_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`
,
T1
.
welfare_list_uv
as
`
2级品类聚合
页uv`
,
T2
.
welfare_list_uv
as
`
美购列表
页-转化uv`
,
T2
.
welfare_list_uv
as
`
2级品类聚合
页-转化uv`
,
T3
.
wel_list_add_uv
as
`
美购列表
页-转化点击加车uv`
,
T3
.
wel_list_add_uv
as
`
2级品类聚合
页-转化点击加车uv`
,
T3
.
wel_list_buy_uv
as
`
美购列表
页-转化点击立即支付uv`
,
T3
.
wel_list_buy_uv
as
`
2级品类聚合
页-转化点击立即支付uv`
,
T3
.
wel_list_msg_uv
as
`
美购列表
页-转化点击私信咨询uv`
,
T3
.
wel_list_msg_uv
as
`
2级品类聚合
页-转化点击私信咨询uv`
,
concat
(
round
(
T2
.
welfare_list_uv
/
T1
.
welfare_list_uv
*
100
,
2
),
'%'
)
as
`
美购列表
页-转化uv率`
,
concat
(
round
(
T2
.
welfare_list_uv
/
T1
.
welfare_list_uv
*
100
,
2
),
'%'
)
as
`
2级品类聚合
页-转化uv率`
,
concat
(
round
(
T2
.
welfare_list_uv
/
T1
.
wel_uv
*
100
,
2
),
'%'
)
as
`
美购列表
页-转化美购uv占比`
,
concat
(
round
(
T2
.
welfare_list_uv
/
T1
.
wel_uv
*
100
,
2
),
'%'
)
as
`
2级品类聚合
页-转化美购uv占比`
,
concat
(
round
(
T3
.
wel_list_add_uv
/
T2
.
welfare_list_uv
*
100
,
2
),
'%'
)
as
`
美购列表
页-点击加车率`
,
concat
(
round
(
T3
.
wel_list_add_uv
/
T2
.
welfare_list_uv
*
100
,
2
),
'%'
)
as
`
2级品类聚合
页-点击加车率`
,
concat
(
round
(
T3
.
wel_list_buy_uv
/
T2
.
welfare_list_uv
*
100
,
2
),
'%'
)
as
`
美购列表
页-点击立即支付率`
,
concat
(
round
(
T3
.
wel_list_buy_uv
/
T2
.
welfare_list_uv
*
100
,
2
),
'%'
)
as
`
2级品类聚合
页-点击立即支付率`
,
concat
(
round
(
T3
.
wel_list_msg_uv
/
T2
.
welfare_list_uv
*
100
,
2
),
'%'
)
as
`
美购列表
页-点击私信咨询率`
,
concat
(
round
(
T3
.
wel_list_msg_uv
/
T2
.
welfare_list_uv
*
100
,
2
),
'%'
)
as
`
2级品类聚合
页-点击私信咨询率`
,
T1
.
my_cart_uv
as
`购物车uv`
,
T1
.
my_cart_uv
as
`购物车uv`
,
T2
.
my_cart_uv
as
`购物车-转化uv`
,
T2
.
my_cart_uv
as
`购物车-转化uv`
,
T3
.
cart_add_uv
as
`购物车-转化点击加车uv`
,
T3
.
cart_add_uv
as
`购物车-转化点击加车uv`
...
@@ -171,7 +171,7 @@ FROM
...
@@ -171,7 +171,7 @@ FROM
SELECT
t1
.
partition_date
SELECT
t1
.
partition_date
,
t1
.
device_type
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
active_type
,
t
2
.
channel
,
t
1
.
channel
,
count
(
distinct
case
when
page_name
=
'welfare_detail'
then
t1
.
cl_id
end
)
as
wel_uv
,
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_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
=
'search_result_welfare'
then
t1
.
cl_id
end
)
as
search_result_welfare_uv
...
@@ -199,31 +199,39 @@ FROM
...
@@ -199,31 +199,39 @@ FROM
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
--AND page_name = 'welfare_detail'
--AND page_name = 'welfare_detail'
AND
action
=
'page_view'
AND
action
=
'page_view'
and
params
[
'is_first'
]
=
1
)
t1
)
t1
JOIN
JOIN
(
(
SELECT
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
select
partition_date
,
device_type
,
device_id
,
active_type
,
t
.
channel
,
case
WHEN
active_type
=
'4'
THEN
'老活跃设备'
from
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
select
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
or
first_channel_source_type
in
(
'promotion_aisi'
,
'promotion_koomobi_km00'
,
'promotion_koomobi_km01'
)
,
case
when
active_type
=
'4'
then
'老活跃设备'
or
first_channel_source_type
like
'%longyuzhixing%'
or
first_channel_source_type
like
'%jingmeng%'
when
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
end
as
active_type
or
first_channel_source_type
like
'%mailuo%'
THEN
'可疑'
,
array
(
case
when
(
a
.
device_id
is
not
null
or
b
.
device_id
is
not
null
WHEN
(
partition_date
>=
'20190601'
and
tmp
.
col2
=
'AI'
)
or
first_channel_source_type
like
'%xinyouxingkong%'
or
(
partition_date
<
'20200301'
AND
partition_date
>=
'20190601'
and
first_channel_source_type
like
'promotion_toutiao_jy%'
)
or
first_channel_source_type
like
'%jingmeng%'
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%'
)))
or
first_channel_source_type
like
'%longyuzhixing%'
THEN
'AI'
ELSE
'其他'
END
,
'合计'
)
as
channel
or
first_channel_source_type
like
'%mailuo%'
)
then
'渠道可疑'
FROM
online
.
ml_device_day_active_status
m
when
tmp
.
is_ai_channel
=
'true'
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:标识
(
select
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
pm
.
tl_pm_ydl
from
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
col3
=
'0204_danlei_channel'
)
tmp
where
partition_day
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
and
partition_day
<
regexp_replace
((
current_date
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
col1
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
LEFT
JOIN
(
SELECT
DISTINCT
device_id
(
select
distinct
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
from
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
ON
m
.
device_id
=
a
.
device_id
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
select
device_id
,
day_id
from
pm
.
tl_pm_channel_d
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
...
@@ -235,6 +243,8 @@ FROM
...
@@ -235,6 +243,8 @@ FROM
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
)
a
LATERAL
VIEW
explode
(
a
.
channel
)
t
AS
channel
)
mas
)
mas
ON
t1
.
cl_id
=
mas
.
device_id
ON
t1
.
cl_id
=
mas
.
device_id
AND
t1
.
partition_date
=
mas
.
partition_date
AND
t1
.
partition_date
=
mas
.
partition_date
...
@@ -247,15 +257,14 @@ FROM
...
@@ -247,15 +257,14 @@ FROM
on
t1
.
cl_id
=
spam_pv
.
device_id
on
t1
.
cl_id
=
spam_pv
.
device_id
WHERE
spam_pv
.
device_id
IS
NULL
WHERE
spam_pv
.
device_id
IS
NULL
)
t1
)
t1
LATERAL
VIEW
explode
(
t1
.
channel
)
t2
AS
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t2
.
channel
)
T1
)
T1
LEFT
JOIN
LEFT
JOIN
(
--不同referrer下的美购详情页uv/uv
(
--不同referrer下的美购详情页uv/uv
SELECT
t1
.
partition_date
SELECT
t1
.
partition_date
,
t1
.
device_type
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
active_type
,
t
2
.
channel
,
t
1
.
channel
,
count
(
distinct
case
when
referrer
=
'welfare_detail'
then
t1
.
cl_id
end
)
as
wel_uv
,
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_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
=
'search_result_welfare'
then
t1
.
cl_id
end
)
as
search_result_welfare_uv
...
@@ -283,31 +292,39 @@ LEFT JOIN
...
@@ -283,31 +292,39 @@ LEFT JOIN
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
page_name
=
'welfare_detail'
AND
page_name
=
'welfare_detail'
AND
action
=
'page_view'
AND
action
=
'page_view'
and
params
[
'is_first'
]
=
1
)
t1
)
t1
JOIN
JOIN
(
(
SELECT
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
select
partition_date
,
device_type
,
device_id
,
active_type
,
t
.
channel
,
case
WHEN
active_type
=
'4'
THEN
'老活跃设备'
from
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
select
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
or
first_channel_source_type
in
(
'promotion_aisi'
,
'promotion_koomobi_km00'
,
'promotion_koomobi_km01'
)
,
case
when
active_type
=
'4'
then
'老活跃设备'
or
first_channel_source_type
like
'%longyuzhixing%'
or
first_channel_source_type
like
'%jingmeng%'
when
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
end
as
active_type
or
first_channel_source_type
like
'%mailuo%'
THEN
'可疑'
,
array
(
case
when
(
a
.
device_id
is
not
null
or
b
.
device_id
is
not
null
WHEN
(
partition_date
>=
'20190601'
and
tmp
.
col2
=
'AI'
)
or
first_channel_source_type
like
'%xinyouxingkong%'
or
(
partition_date
<
'20200301'
AND
partition_date
>=
'20190601'
and
first_channel_source_type
like
'promotion_toutiao_jy%'
)
or
first_channel_source_type
like
'%jingmeng%'
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%'
)))
or
first_channel_source_type
like
'%longyuzhixing%'
THEN
'AI'
ELSE
'其他'
END
,
'合计'
)
as
channel
or
first_channel_source_type
like
'%mailuo%'
)
then
'渠道可疑'
FROM
online
.
ml_device_day_active_status
m
when
tmp
.
is_ai_channel
=
'true'
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:标识
(
select
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
pm
.
tl_pm_ydl
from
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
col3
=
'0204_danlei_channel'
)
tmp
where
partition_day
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
and
partition_day
<
regexp_replace
((
current_date
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
col1
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
LEFT
JOIN
(
SELECT
DISTINCT
device_id
(
select
distinct
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
from
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
ON
m
.
device_id
=
a
.
device_id
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
select
device_id
,
day_id
from
pm
.
tl_pm_channel_d
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
...
@@ -319,6 +336,8 @@ LEFT JOIN
...
@@ -319,6 +336,8 @@ LEFT JOIN
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
)
a
LATERAL
VIEW
explode
(
a
.
channel
)
t
AS
channel
)
mas
)
mas
ON
t1
.
cl_id
=
mas
.
device_id
ON
t1
.
cl_id
=
mas
.
device_id
AND
t1
.
partition_date
=
mas
.
partition_date
AND
t1
.
partition_date
=
mas
.
partition_date
...
@@ -331,8 +350,7 @@ LEFT JOIN
...
@@ -331,8 +350,7 @@ LEFT JOIN
on
t1
.
cl_id
=
spam_pv
.
device_id
on
t1
.
cl_id
=
spam_pv
.
device_id
WHERE
spam_pv
.
device_id
IS
NULL
WHERE
spam_pv
.
device_id
IS
NULL
)
t1
)
t1
LATERAL
VIEW
explode
(
t1
.
channel
)
t2
AS
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t2
.
channel
)
T2
)
T2
ON
T1
.
partition_date
=
T2
.
partition_date
ON
T1
.
partition_date
=
T2
.
partition_date
and
T1
.
device_type
=
T2
.
device_type
and
T1
.
device_type
=
T2
.
device_type
...
@@ -343,7 +361,7 @@ LEFT JOIN
...
@@ -343,7 +361,7 @@ LEFT JOIN
SELECT
t1
.
partition_date
SELECT
t1
.
partition_date
,
t1
.
device_type
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
active_type
,
t
2
.
channel
,
t
1
.
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_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
=
'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
=
'welfare_detail'
and
action
in
(
'welfare_detail_click_message'
,
'on_click_button'
)
then
t1
.
cl_id
end
)
as
wel_msg_uv
...
@@ -438,28 +456,35 @@ LEFT JOIN
...
@@ -438,28 +456,35 @@ LEFT JOIN
)
t1
)
t1
JOIN
JOIN
(
(
SELECT
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
select
partition_date
,
device_type
,
device_id
,
active_type
,
t
.
channel
,
case
WHEN
active_type
=
'4'
THEN
'老活跃设备'
from
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
select
partition_date
,
device_os_type
as
device_type
,
m
.
device_id
or
first_channel_source_type
in
(
'promotion_aisi'
,
'promotion_koomobi_km00'
,
'promotion_koomobi_km01'
)
,
case
when
active_type
=
'4'
then
'老活跃设备'
or
first_channel_source_type
like
'%longyuzhixing%'
or
first_channel_source_type
like
'%jingmeng%'
when
active_type
in
(
'1'
,
'2'
)
then
'新增设备'
end
as
active_type
or
first_channel_source_type
like
'%mailuo%'
THEN
'可疑'
,
array
(
case
when
(
a
.
device_id
is
not
null
or
b
.
device_id
is
not
null
WHEN
(
partition_date
>=
'20190601'
and
tmp
.
col2
=
'AI'
)
or
first_channel_source_type
like
'%xinyouxingkong%'
or
(
partition_date
<
'20200301'
AND
partition_date
>=
'20190601'
and
first_channel_source_type
like
'promotion_toutiao_jy%'
)
or
first_channel_source_type
like
'%jingmeng%'
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%'
)))
or
first_channel_source_type
like
'%longyuzhixing%'
THEN
'AI'
ELSE
'其他'
END
,
'合计'
)
as
channel
or
first_channel_source_type
like
'%mailuo%'
)
then
'渠道可疑'
FROM
online
.
ml_device_day_active_status
m
when
tmp
.
is_ai_channel
=
'true'
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:标识
(
select
code
,
is_spam
,
is_ai_channel
,
partition_day
FROM
pm
.
tl_pm_ydl
from
DIM
.
DIM_AI_CHANNEL_ZP_NEW
WHERE
col3
=
'0204_danlei_channel'
)
tmp
where
partition_day
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
and
partition_day
<
regexp_replace
((
current_date
),
'-'
,
''
)
)
tmp
on
first_channel_source_type
=
tmp
.
col1
on
first_channel_source_type
=
tmp
.
code
and
m
.
partition_date
=
tmp
.
partition_day
LEFT
JOIN
LEFT
JOIN
(
SELECT
DISTINCT
device_id
(
select
distinct
device_id
FROM
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
from
al
.
al_pm_ct_dv_deviceappversionrollbackfrom20190101_d
WHERE
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
2
)
,
'-'
,
''
))
a
ON
m
.
device_id
=
a
.
device_id
ON
m
.
device_id
=
a
.
device_id
LEFT
JOIN
(
select
device_id
,
day_id
from
pm
.
tl_pm_channel_d
where
partition_day
=
regexp_replace
(
DATE_SUB
(
current_date
,
1
)
,
'-'
,
''
)
group
by
device_id
,
day_id
)
b
ON
m
.
device_id
=
b
.
device_id
AND
m
.
partition_date
=
b
.
day_id
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
where
partition_date
>=
regexp_replace
(
DATE_SUB
(
current_date
,
90
)
,
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
partition_date
<
regexp_replace
((
current_date
),
'-'
,
''
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
AND
active_type
in
(
'1'
,
'2'
,
'4'
)
...
@@ -471,6 +496,8 @@ LEFT JOIN
...
@@ -471,6 +496,8 @@ LEFT JOIN
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_qianka'
,
'promotion_xiaoyu'
,
'promotion_dianru'
,
'promotion_malioaso'
,
'promotion_malioaso-shequ'
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
,
'promotion_shike'
,
'promotion_julang_jl03'
,
'promotion_zuimei'
,
''
,
'unknown'
)
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
AND
first_channel_source_type
not
like
'promotion
\_
jf
\_
%'
)
a
LATERAL
VIEW
explode
(
a
.
channel
)
t
AS
channel
)
mas
)
mas
ON
t1
.
cl_id
=
mas
.
device_id
ON
t1
.
cl_id
=
mas
.
device_id
AND
t1
.
partition_date
=
mas
.
partition_date
AND
t1
.
partition_date
=
mas
.
partition_date
...
@@ -483,8 +510,7 @@ LEFT JOIN
...
@@ -483,8 +510,7 @@ LEFT JOIN
on
t1
.
cl_id
=
spam_pv
.
device_id
on
t1
.
cl_id
=
spam_pv
.
device_id
WHERE
spam_pv
.
device_id
IS
NULL
WHERE
spam_pv
.
device_id
IS
NULL
)
t1
)
t1
LATERAL
VIEW
explode
(
t1
.
channel
)
t2
AS
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t1
.
channel
GROUP
BY
t1
.
partition_date
,
t1
.
device_type
,
t1
.
active_type
,
t2
.
channel
)
T3
)
T3
ON
T1
.
partition_date
=
T3
.
partition_date
ON
T1
.
partition_date
=
T3
.
partition_date
and
T1
.
device_type
=
T3
.
device_type
and
T1
.
device_type
=
T3
.
device_type
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment