-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathunique_fea_creator.sql
328 lines (326 loc) · 11.1 KB
/
unique_fea_creator.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
DROP TABLE if EXISTS train_unique_fea;
CREATE table train_unique_fea as SELECT a.event_id,a.gmt_occur,a.user_id
,device_sign_unique
,pay_scene_unique
,operation_channel_unique
,client_ip_unique
,mobile_oper_platform_unique
,network_unique
,ip_dev_unique
,scene_dev_unique
,plat_dev_unique
,chan_dev_unique
,chan_plat_unique
,scene_chan_plat_unique
,scene_chan_unique
,scene_oper_unique
,client_ip_prov_city_unique
,ip_prov_city_unique
,cert_prov_city_unique
,card_mobile_prov_city_unique
,card_cert_prov_city_unique
from atec_1000w_ins_data as a
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.device_sign) as device_sign_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,device_sign,gmt_occur
from atec_1000w_ins_data
group by user_id,device_sign,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as at1
on a.user_id = at1.user_id and a.gmt_occur = at1.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.pay_scene) as pay_scene_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,pay_scene,gmt_occur
from atec_1000w_ins_data
group by user_id,pay_scene,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as at2
on a.user_id = at2.user_id and a.gmt_occur = at2.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.operation_channel) as operation_channel_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,operation_channel,gmt_occur
from atec_1000w_ins_data
group by user_id,operation_channel,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as at3
on a.user_id = at3.user_id and a.gmt_occur = at3.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.client_ip) as client_ip_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,client_ip,gmt_occur
from atec_1000w_ins_data
group by user_id,client_ip,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as at4
on a.user_id = at4.user_id and a.gmt_occur = at4.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.mobile_oper_platform) as mobile_oper_platform_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,mobile_oper_platform,gmt_occur
from atec_1000w_ins_data
group by user_id,mobile_oper_platform,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as at5
on a.user_id = at5.user_id and a.gmt_occur = at5.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.network) as network_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,network,gmt_occur
from atec_1000w_ins_data
group by user_id,network,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as at6
on a.user_id = at6.user_id and a.gmt_occur = at6.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.device_sign,t2.client_ip) as ip_dev_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,device_sign,client_ip,gmt_occur
from atec_1000w_ins_data
group by user_id,device_sign,client_ip,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ct1
on a.user_id = ct1.user_id and a.gmt_occur = ct1.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.device_sign,t2.pay_scene) as scene_dev_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,device_sign,pay_scene,gmt_occur
from atec_1000w_ins_data
group by user_id,device_sign,pay_scene,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ct2
on a.user_id = ct2.user_id and a.gmt_occur = ct2.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.device_sign,t2.mobile_oper_platform) as plat_dev_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,device_sign,mobile_oper_platform,gmt_occur
from atec_1000w_ins_data
group by user_id,device_sign,mobile_oper_platform,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ct3
on a.user_id = ct3.user_id and a.gmt_occur = ct3.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.device_sign,t2.operation_channel) as chan_dev_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,device_sign,operation_channel,gmt_occur
from atec_1000w_ins_data
group by user_id,device_sign,operation_channel,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ct4
on a.user_id = ct4.user_id and a.gmt_occur = ct4.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.mobile_oper_platform,t2.operation_channel) as chan_plat_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,mobile_oper_platform,operation_channel,gmt_occur
from atec_1000w_ins_data
group by user_id,mobile_oper_platform,operation_channel,gmt_occur) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ct5
on a.user_id = ct5.user_id and a.gmt_occur = ct5.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.mobile_oper_platform,t2.operation_channel,t2.pay_scene) as scene_chan_plat_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,mobile_oper_platform,operation_channel,gmt_occur,pay_scene
from atec_1000w_ins_data
group by user_id,mobile_oper_platform,operation_channel,gmt_occur,pay_scene) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ct6
on a.user_id = ct6.user_id and a.gmt_occur = ct6.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.operation_channel,t2.pay_scene) as scene_chan_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,operation_channel,gmt_occur,pay_scene
from atec_1000w_ins_data
group by user_id,operation_channel,gmt_occur,pay_scene) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ct7
on a.user_id = ct7.user_id and a.gmt_occur = ct7.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.mobile_oper_platform,t2.pay_scene) as scene_oper_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,mobile_oper_platform,gmt_occur,pay_scene
from atec_1000w_ins_data
group by user_id,mobile_oper_platform,gmt_occur,pay_scene) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ct8
on a.user_id = ct8.user_id and a.gmt_occur = ct8.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.ip_prov,t2.ip_city) as ip_prov_city_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,ip_prov,gmt_occur,ip_city
from atec_1000w_ins_data
group by user_id,ip_prov,gmt_occur,ip_city) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ipt1
on a.user_id = ipt1.user_id and a.gmt_occur = ipt1.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.cert_prov,t2.cert_city) as cert_prov_city_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,cert_prov,gmt_occur,cert_city
from atec_1000w_ins_data
group by user_id,cert_prov,gmt_occur,cert_city) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ipt2
on a.user_id = ipt2.user_id and a.gmt_occur = ipt2.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.card_cert_prov,t2.card_cert_city) as card_cert_prov_city_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,card_cert_prov,gmt_occur,card_cert_city
from atec_1000w_ins_data
group by user_id,card_cert_prov,gmt_occur,card_cert_city) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ipt3
on a.user_id = ipt3.user_id and a.gmt_occur = ipt3.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.card_mobile_prov,t2.card_mobile_city) as card_mobile_prov_city_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,card_mobile_prov,gmt_occur,card_mobile_city
from atec_1000w_ins_data
group by user_id,card_mobile_prov,gmt_occur,card_mobile_city) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ipt4
on a.user_id = ipt4.user_id and a.gmt_occur = ipt4.gmt_occur
left join(
select t1.user_id ,t1.gmt_occur
,count(distinct t2.ip_prov,t2.ip_city,t2.client_ip) as client_ip_prov_city_unique
from
(select user_id,gmt_occur
from atec_1000w_ins_data
group by user_id,gmt_occur) as t1
left join
(select user_id,ip_prov,gmt_occur,ip_city,client_ip
from atec_1000w_ins_data
group by user_id,ip_prov,gmt_occur,ip_city,client_ip) as t2
on t1.user_id = t2.user_id
where t1.gmt_occur>=t2.gmt_occur
group by t1.user_id,t1.gmt_occur
) as ipt5
on a.user_id = ipt5.user_id and a.gmt_occur = ipt5.gmt_occur