-
Notifications
You must be signed in to change notification settings - Fork 0
/
Queries.csv
We can't make this file beautiful and searchable because it's too large.
15104 lines (13462 loc) · 604 KB
/
Queries.csv
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
descripcion,metricas,query,owner
Delay para notificaciones de Mantika.,"site, execution id, domain, created at date, user timestamp, y batch type","WITH NOTIF AS (
SELECT
a.site_id,
a.user_id,
a.domain_id,
a.score_id,
date_add(b.user_timestamp, INTERVAL 4 hour) as user_timestamp,
created_at as created_at_date,
coalesce(batch_type, 'NOSENT') batch_type,
score
FROM ( SELECT * FROM `meli-bi-data.SBOX_MANTIKAMARKETING.MARKETING_LOGS_DATA` WHERE CAST(created_at AS DATE) >= '2022-05-01'
AND ARRAY_LENGTH(SPLIT(score_id, '_')) > 1 AND site_id IN ('MLB', 'MLA', 'MLM')
AND left(score_id,1) ='0'
) a
LEFT JOIN (SELECT * FROM `meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports` WHERE event_type = 'sent' and ARRAY_LENGTH(SPLIT(execution_id, '_')) > 1) b ON split(b.execution_id, '_')[OFFSET (1)] = SPLIT(a.score_id, '_')[OFFSET (1)]
GROUP BY 1,2,3,4,5,6,7,8
), TYPE_IDENTIFICADOR AS (
SELECT
a.site_id,
a.user_id,
a.batch_type,
count(*)
FROM NOTIF a
group by 1,2,3
)
SELECT distinct
a.site_id,
a.score_id,
domain_id,
created_at_date,
a.user_timestamp,
a.batch_type,
--count(distinct a.user_id),
--count(distinct SPLIT(score_id, '_')[OFFSET (1)]) as cant_notis,
--CASE WHEN other_noti = -1 then 'not_sent_again' ELSE 'sent_again' END sent_again,
-- APPROX_QUANTILES(score, 10) score_dist,
FROM NOTIF a LEFT JOIN TYPE_IDENTIFICADOR b
ON a.user_id = b.user_id
and a.site_id = b.site_id
GROUP BY 1,2,3,4,5,6
;",Jose
Bloqueos por hora.,"created at date, created at hours, user, batch type, notis y bloqueos","WITH NOTIF AS (
SELECT
a.site_id,
a.user_id,
a.domain_id,
a.score_id,
date(DATE_SUB(cast(created_at as timestamp) , INTERVAL 4 hour)) as created_at_date,
extract(hour from DATE_SUB(cast(created_at as timestamp) , INTERVAL 4 hour)) as created_at_hours,
DATE_SUB(cast(created_at as timestamp) , INTERVAL 4 hour) as user_timestamp,
coalesce(batch_type, 'NOSENT') batch_type,
coalesce(batch_credit, 'NOSENT') batch_credit_hermes,
score
FROM ( SELECT * FROM `meli-bi-data.SBOX_MANTIKAMARKETING.MARKETING_LOGS_DATA` WHERE CAST(created_at AS DATE) >= '2022-05-3' and CAST(created_at AS DATE) <= '2022-05-18'
AND ARRAY_LENGTH(SPLIT(score_id, '_')) > 1 AND site_id IN ('MLB' )
AND left(score_id,1) ='0'
) a
LEFT JOIN (SELECT * FROM `meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports` WHERE ARRAY_LENGTH(SPLIT(execution_id, '_')) > 1) b ON split(b.execution_id, '_')[OFFSET (1)] = SPLIT(a.score_id, '_')[OFFSET (1)]
GROUP BY 1,2,3,4,5,6,7,8,9,10
), TYPE_IDENTIFICADOR AS (
SELECT
date_trunc(a.created_at_date, month) as month,
a.site_id,
a.user_id,
a.batch_type,
count(*)
FROM NOTIF a
WHERE extract(day from a.created_at_date) NOT IN (1,2,29,30,31)
and a.batch_type != 'NOSENT'
group by 1,2,3,4
)
SELECT distinct
--domain_id,
created_at_date,
created_at_hours,
case when b.batch_type is null then ""no_enviados_ese_mes"" else b.batch_type end as identificador_por_mes,
a.batch_type,
count(distinct a.user_id),
count(distinct SPLIT(score_id, '_')[OFFSET (1)]) as cant_notis,
--CASE WHEN other_noti = -1 then 'not_sent_again' ELSE 'sent_again' END sent_again,
-- APPROX_QUANTILES(score, 10) score_dist,
FROM NOTIF a LEFT JOIN TYPE_IDENTIFICADOR b
ON date_trunc(a.created_at_date, month) = b.month
AND a.user_id = b.user_id
and a.site_id = b.site_id
GROUP BY 1,2,3,4
;",Jose
Reporte semanal según Experiment Type y Open Rate.,"month, site, experiment type, date, week, users, buyers, orders, gmv para test y control group, shown y open","with OpR AS (
WITH opens AS (
SELECT
notification_date,
sit_site_id,
CUS_CUST_ID,
campaign_id,
execution_id,
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports
WHERE 1=1
AND notification_date >= '2022-02-09'
AND event_type IN ('open')
),
showns AS (
SELECT
notification_date,
sit_site_id,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) in ('4', '6', '7') THEN 'resend'
ELSE
CASE WHEN experiment = '9' then 'resend'
WHEN experiment = 'F' THEN 'resend'
ELSE 'remarketing' END END experiment_type,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) = '4' THEN 'resend_v6'
WHEN left(execution_id,1) = '6' THEN 'resend_10_v6'
ELSE
CASE WHEN experiment = '7' then 'v17'
WHEN experiment = '9' THEN 'resend_v6'
WHEN experiment IN ('B', 'D', '8') THEN 'remove_v6'
WHEN experiment IN ('A', 'B') THEN 'reorder_with_redis'
WHEN experiment IN ('C', 'D') THEN 'reorder_with_postgres'
WHEN experiment = 'E' THEN 'v19'
WHEN experiment = 'F' THEN 'resend_10_v6'
ELSE 'v6' END END experiment,
CUS_CUST_ID,
batch_credit,
campaign_id,
execution_id,
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports
WHERE 1=1
AND notification_date >= '2022-02-09'
AND event_type IN ('shown')
and campaign_id = 'REMARKETING_MANTIKA'
)
SELECT
a.notification_date ,
a.SIT_SITE_ID,
a.experiment_type,
--experiment,
count(DISTINCT concat(b.execution_id, b.cus_cust_id)) / NULLIF(count(DISTINCT concat(a.execution_id, a.cus_cust_id)), 0) open_rate,
count(DISTINCT concat(b.execution_id, b.cus_cust_id)) open,
count(DISTINCT concat(a.execution_id, a.cus_cust_id)) shown
FROM showns a
LEFT JOIN opens b ON concat(a.execution_id, a.cus_cust_id) = concat(b.execution_id, b.cus_cust_id)
GROUP BY 1,2,3
),
ORDERS as
(
SELECT cus_cust_id AS user_id,
-- ord_created_dttm esta sin timezone pero con horario de -4 (le sumamos 4 para corregir)
DATE_ADD(tim_day_winning_time, INTERVAL 4 HOUR) AS FECHA_ORDER,
SIT_SITE_ID as site_id,
ord_order_id AS order_id,
item_id,
domain_id,
GMV_USD
FROM meli-bi-data.SBOX_MANTIKAMARKETING.bids_marketing_reports
WHERE 1=1
AND tim_day_winning_date >= date_sub(date_trunc(current_date, MONTH), INTERVAL 1 MONTH)
AND tim_day_winning_date < current_date()
AND SIT_SITE_ID in ('MLA','MLM','MLB','MLC','MCO','MLU')
)
,NOTIF AS
(
SELECT
DATE_ADD(user_timestamp, INTERVAL 4 HOUR) as notif_dttm,
sit_site_id as site_id,
cus_cust_id as user_id,
campaign_id campaign,
batch_credit,
domain_id,
item_id_1,
item_id_2,
item_id_3,
item_id_4,
item_id_5,
batch_type,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) = '4' THEN 'resend_v6'
WHEN left(execution_id,1) = '6' THEN 'resend_10_v6'
ELSE
CASE WHEN experiment = '7' then 'v17'
WHEN experiment = '9' THEN 'resend_v6'
WHEN experiment IN ('B', 'D', '8') THEN 'remove_v6'
WHEN experiment IN ('A', 'B') THEN 'reorder_with_redis'
WHEN experiment IN ('C', 'D') THEN 'reorder_with_postgres'
WHEN experiment = 'E' THEN 'v19'
WHEN experiment = 'F' THEN 'resend_10_v6'
ELSE 'v6' END END experiment,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) in ('4', '6', '7') THEN 'resend'
ELSE
CASE WHEN experiment = '9' then 'resend'
WHEN experiment = 'F' THEN 'resend'
ELSE 'remarketing' END END experiment_type,
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports as A
WHERE 1= 1
AND campaign_id = 'REMARKETING_MANTIKA'
AND event_type IN ('sent') --, 'shown', 'open')
AND notification_date >= date_sub(date_trunc(current_date - 1, MONTH), INTERVAL 1 MONTH)
AND notification_date < current_date() -1
AND sit_site_id in ('MLA','MLM','MLB','MLC','MCO','MLU')
),
orders_atribuidas AS
(
SELECT order_id, fecha_order, buyer_id, site_id, campaign, batch_type, notif_2_day, gmv_usd, experiment_type, --experiment
FROM (
SELECT
o.order_id,
o.fecha_order,
o.user_id as buyer_id,
o.site_id,
o.gmv_usd,
n.campaign,
-- n.batch_credit,
n.batch_type,
n.experiment_type experiment_type,
--n.experiment experiment,
n.notif_dttm notif_2_day,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR)) THEN n.notif_dttm END notif_24,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 1 HOUR)) THEN n.notif_dttm END notif_1,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR) AND n.domain_id = o.domain_id) THEN n.notif_dttm END notif_24_domain,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR)
AND (o.item_id IN (n.item_id_1, n.item_id_2, n.item_id_3, n.item_id_4, n.item_id_5))) THEN n.notif_dttm END notif_24_items,
RANK() OVER (PARTITION BY o.ORDER_ID ORDER BY n.notif_dttm DESC) AS ORDEN_2
FROM orders o
LEFT JOIN notif n
ON n.user_id = o.user_id
and n.site_id = o.site_id
AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 2 DAY)
AND n.notif_dttm < o.FECHA_ORDER
)
WHERE ORDEN_2 = 1
)
,total_orders_atribuidas as
(
select
site_id,
campaign,
--experiment,
experiment_type,
-- batch_credit,
date(notif_2_day) fecha,
-- 2 Days
count(distinct case when batch_type='test' then buyer_id end) buyers_2day_test,
count(distinct case when batch_type='test' then order_id end) orders_2day_test,
sum(case when batch_type='test' then gmv_usd end) gmv_2day_test,
count(distinct case when batch_type='cg' then buyer_id end) buyers_2day_cg,
count(distinct case when batch_type='cg' then order_id end) orders_2day_cg,
sum(case when batch_type='cg' then gmv_usd end) gmv_2day_cg,
-- 24 hours
-- count(distinct case when batch_type='test' AND notif_24 IS NOT NULL then buyer_id end) buyers_test_24,
-- count(distinct case when batch_type='test' AND notif_24 IS NOT NULL then order_id end) orders_test_24,
-- sum(case when batch_type='test' AND notif_24 IS NOT NULL then gmv_usd end) gmv_test_2,
-- count(distinct case when batch_type='cg' AND notif_24 IS NOT NULL then buyer_id end) buyers_cg_2,
-- count(distinct case when batch_type='cg' AND notif_24 IS NOT NULL then order_id end) orders_cg_2,
-- sum(case when batch_type='cg' AND notif_24 IS NOT NULL then gmv_usd end) gmv_cg,
-- 24 hours same domain
from orders_atribuidas
where notif_2_day is not null -- solo orders atribuidas
group by 1,2,3,4
)
,
total_sent as
(
select
site_id,
campaign ,
--experiment,
experiment_type,
--batch_credit,
date(notif_dttm) fecha,
count(distinct case when batch_type='test' then user_id end) users_test,
count(distinct case when batch_type='cg' then user_id end) users_cg
from notif
group by 1,2,3,4
)
select
date_trunc(o.fecha, MONTH) month_notif,
o.site_id sit_site_id,
--o.campaign campaign_id,
--o.experiment,
o.experiment_type,
o.fecha notification_date,
date_trunc(o.fecha, week(saturday)) weeks,
--o.batch_Credit,
users_test,
buyers_2day_test,
orders_2day_test,
gmv_2day_test,
users_cg, buyers_2day_cg, orders_2day_cg, gmv_2day_cg,
--buyers_2day_test/NULLIF(users_test,0) -buyers_2day_cg / NULLIF(users_cg, 0) lift,
COALESCE(buyers_2day_test - (buyers_2day_cg * users_test / NULLIF(users_cg, 0)), 0) inc_buyers,
COALESCE(orders_2day_test - (orders_2day_cg * users_test / NULLIF(users_cg, 0)), 0) inc_orders,
CAST(COALESCE(gmv_2day_test - (gmv_2day_cg * users_test / NULLIF(users_cg, 0)), 0) AS FLOAT64) inc_gmv,
or_.shown,
or_.open
from total_orders_atribuidas o
left join total_sent n on o.site_id=n.site_id and o.campaign=n.campaign and o.fecha=n.fecha and o.experiment_type=n.experiment_type -- AND o.batch_credit = n.batch_credit
LEFT JOIN (
SELECT sit_site_id, notification_date, experiment_type, shown,open
FROM OpR) or_
ON o.fecha = or_.notification_date AND o.site_id = or_.sit_site_id AND o.experiment_type = or_.experiment_type;",Jose
Reporte semanal por Experimento y Open Rate,"month, site, experiment type, date, week, experiment, users, buyers, orders, gmv para test y control group, shown y open","with OpR AS (
WITH opens AS (
SELECT
notification_date,
sit_site_id,
CUS_CUST_ID,
campaign_id,
execution_id,
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports
WHERE 1=1
AND notification_date >= '2022-02-09'
AND event_type IN ('open')
),
showns AS (
SELECT
notification_date,
sit_site_id,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) in ('4', '6', '7') THEN 'resend'
ELSE
CASE WHEN experiment = '9' then 'resend'
WHEN experiment = 'F' THEN 'resend'
ELSE 'remarketing' END END experiment_type,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) = '4' THEN 'resend_v6'
WHEN left(execution_id,1) = '6' THEN 'resend_10_v6'
ELSE
CASE WHEN experiment = '7' then 'v17'
WHEN experiment = '9' THEN 'resend_v6'
WHEN experiment IN ('B', 'D', '8') THEN 'remove_v6'
WHEN experiment IN ('A', 'B') THEN 'reorder_with_redis'
WHEN experiment IN ('C', 'D') THEN 'reorder_with_postgres'
WHEN experiment = 'E' THEN 'v19'
WHEN experiment = 'F' THEN 'resend_10_v6'
ELSE 'v6' END END experiment,
CUS_CUST_ID,
batch_credit,
campaign_id,
execution_id,
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports
WHERE 1=1
AND notification_date >= '2022-02-09'
AND event_type IN ('shown')
and campaign_id = 'REMARKETING_MANTIKA'
)
SELECT
a.notification_date ,
a.SIT_SITE_ID,
a.experiment_type,
experiment,
count(DISTINCT concat(b.execution_id, b.cus_cust_id)) / NULLIF(count(DISTINCT concat(a.execution_id, a.cus_cust_id)), 0) open_rate,
count(DISTINCT concat(b.execution_id, b.cus_cust_id)) open,
count(DISTINCT concat(a.execution_id, a.cus_cust_id)) shown
FROM showns a
LEFT JOIN opens b ON concat(a.execution_id, a.cus_cust_id) = concat(b.execution_id, b.cus_cust_id)
GROUP BY 1,2,3,4
),
ORDERS as
(
SELECT cus_cust_id AS user_id,
-- ord_created_dttm esta sin timezone pero con horario de -4 (le sumamos 4 para corregir)
DATE_ADD(tim_day_winning_time, INTERVAL 4 HOUR) AS FECHA_ORDER,
SIT_SITE_ID as site_id,
ord_order_id AS order_id,
item_id,
domain_id,
GMV_USD
FROM meli-bi-data.SBOX_MANTIKAMARKETING.bids_marketing_reports
WHERE 1=1
AND tim_day_winning_date >= date_sub(date_trunc(current_date, MONTH), INTERVAL 1 MONTH)
AND tim_day_winning_date < current_date()
AND SIT_SITE_ID in ('MLA','MLM','MLB','MLC','MCO','MLU')
)
,NOTIF AS
(
SELECT
DATE_ADD(user_timestamp, INTERVAL 4 HOUR) as notif_dttm,
sit_site_id as site_id,
cus_cust_id as user_id,
campaign_id campaign,
batch_credit,
domain_id,
item_id_1,
item_id_2,
item_id_3,
item_id_4,
item_id_5,
batch_type,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) = '4' THEN 'resend_v6'
WHEN left(execution_id,1) = '6' THEN 'resend_10_v6'
ELSE
CASE WHEN experiment = '7' then 'v17'
WHEN experiment = '9' THEN 'resend_v6'
WHEN experiment IN ('B', 'D', '8') THEN 'remove_v6'
WHEN experiment IN ('A', 'B') THEN 'reorder_with_redis'
WHEN experiment IN ('C', 'D') THEN 'reorder_with_postgres'
WHEN experiment = 'E' THEN 'v19'
WHEN experiment = 'F' THEN 'resend_10_v6'
ELSE 'v6' END END experiment,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) in ('4', '6', '7') THEN 'resend'
ELSE
CASE WHEN experiment = '9' then 'resend'
WHEN experiment = 'F' THEN 'resend'
ELSE 'remarketing' END END experiment_type,
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports as A
WHERE 1= 1
AND campaign_id = 'REMARKETING_MANTIKA'
AND event_type IN ('sent') --, 'shown', 'open')
AND notification_date >= date_sub(date_trunc(current_date - 1, MONTH), INTERVAL 1 MONTH)
AND notification_date < current_date() -1
AND sit_site_id in ('MLA','MLM','MLB','MLC','MCO','MLU')
),
orders_atribuidas AS
(
SELECT order_id, fecha_order, buyer_id, site_id, campaign, batch_type, notif_2_day, gmv_usd, experiment_type, experiment
FROM (
SELECT
o.order_id,
o.fecha_order,
o.user_id as buyer_id,
o.site_id,
o.gmv_usd,
n.campaign,
-- n.batch_credit,
n.batch_type,
n.experiment_type experiment_type,
n.experiment experiment,
n.notif_dttm notif_2_day,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR)) THEN n.notif_dttm END notif_24,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 1 HOUR)) THEN n.notif_dttm END notif_1,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR) AND n.domain_id = o.domain_id) THEN n.notif_dttm END notif_24_domain,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR)
AND (o.item_id IN (n.item_id_1, n.item_id_2, n.item_id_3, n.item_id_4, n.item_id_5))) THEN n.notif_dttm END notif_24_items,
RANK() OVER (PARTITION BY o.ORDER_ID ORDER BY n.notif_dttm DESC) AS ORDEN_2
FROM orders o
LEFT JOIN notif n
ON n.user_id = o.user_id
and n.site_id = o.site_id
AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 2 DAY)
AND n.notif_dttm < o.FECHA_ORDER
)
WHERE ORDEN_2 = 1
)
,total_orders_atribuidas as
(
select
site_id,
campaign,
experiment,
experiment_type,
-- batch_credit,
date(notif_2_day) fecha,
-- 2 Days
count(distinct case when batch_type='test' then buyer_id end) buyers_2day_test,
count(distinct case when batch_type='test' then order_id end) orders_2day_test,
sum(case when batch_type='test' then gmv_usd end) gmv_2day_test,
count(distinct case when batch_type='cg' then buyer_id end) buyers_2day_cg,
count(distinct case when batch_type='cg' then order_id end) orders_2day_cg,
sum(case when batch_type='cg' then gmv_usd end) gmv_2day_cg,
-- 24 hours
-- count(distinct case when batch_type='test' AND notif_24 IS NOT NULL then buyer_id end) buyers_test_24,
-- count(distinct case when batch_type='test' AND notif_24 IS NOT NULL then order_id end) orders_test_24,
-- sum(case when batch_type='test' AND notif_24 IS NOT NULL then gmv_usd end) gmv_test_2,
-- count(distinct case when batch_type='cg' AND notif_24 IS NOT NULL then buyer_id end) buyers_cg_2,
-- count(distinct case when batch_type='cg' AND notif_24 IS NOT NULL then order_id end) orders_cg_2,
-- sum(case when batch_type='cg' AND notif_24 IS NOT NULL then gmv_usd end) gmv_cg,
-- 24 hours same domain
from orders_atribuidas
where notif_2_day is not null -- solo orders atribuidas
group by 1,2,3,4,5
)
,
total_sent as
(
select
site_id,
campaign ,
experiment,
experiment_type,
--batch_credit,
date(notif_dttm) fecha,
count(distinct case when batch_type='test' then user_id end) users_test,
count(distinct case when batch_type='cg' then user_id end) users_cg
from notif
group by 1,2,3,4,5
)
select
date_trunc(o.fecha, MONTH) month_notif,
o.site_id sit_site_id,
--o.campaign campaign_id,
o.experiment,
o.experiment_type,
o.fecha notification_date,
date_trunc(o.fecha, week(saturday)) weeks,
--o.batch_Credit,
users_test,
buyers_2day_test,
orders_2day_test,
gmv_2day_test,
users_cg, buyers_2day_cg, orders_2day_cg, gmv_2day_cg,
--buyers_2day_test/NULLIF(users_test,0) -buyers_2day_cg / NULLIF(users_cg, 0) lift,
COALESCE(buyers_2day_test - (buyers_2day_cg * users_test / NULLIF(users_cg, 0)), 0) inc_buyers,
COALESCE(orders_2day_test - (orders_2day_cg * users_test / NULLIF(users_cg, 0)), 0) inc_orders,
CAST(COALESCE(gmv_2day_test - (gmv_2day_cg * users_test / NULLIF(users_cg, 0)), 0) AS FLOAT64) inc_gmv,
or_.shown,
or_.open
from total_orders_atribuidas o
left join total_sent n on o.site_id=n.site_id and o.campaign=n.campaign and o.fecha=n.fecha and o.experiment=n.experiment and o.experiment_type=n.experiment_type -- AND o.batch_credit = n.batch_credit
LEFT JOIN (
SELECT sit_site_id, notification_date, experiment_type, experiment,shown,open
FROM OpR) or_
ON o.fecha = or_.notification_date AND o.site_id = or_.sit_site_id AND o.experiment_type = or_.experiment_type and o.experiment = or_.experiment;",Jose
"Users, buyers y notificaciones de xsell con atribución Ttems 48 horas.","site, experiment, date, users, buyers y orders de test y cg, incremental buyers, incremental orders, cvr test, cvr control group, lift buyers y lift otders, shown, open y open rate","with OpR AS (
WITH opens AS (
SELECT
notification_date,
sit_site_id,
CUS_CUST_ID,
campaign_id,
execution_id,
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports
WHERE 1=1
AND notification_date >= '2022-05-06'
AND event_type IN ('open')
),
showns AS (
SELECT
DATE(date_trunc(date_add(user_timestamp, INTERVAL 4 HOUR), DAY)) notification_date,
sit_site_id,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) = '4' THEN 'resend_1'
WHEN left(execution_id,1) = '8' THEN 'resend_7'
WHEN left(execution_id,1) = '6' THEN 'resend_10'
WHEN left(execution_id,1) = '5' THEN 'resend_3'
WHEN left(execution_id,1) = '7' THEN 'resend_xsell'
WHEN left(execution_id,1) = '9' THEN 'resend_morning'
ELSE
CASE WHEN experiment = '7' then 'v17'
WHEN experiment = '9' THEN 'resend_1'
WHEN experiment IN ('B', 'D', '8') THEN 'remove_1'
WHEN experiment IN ('A', 'B') THEN 'reorder_with_redis'
WHEN experiment IN ('C', 'D') THEN 'reorder_with_postgres'
WHEN experiment = 'E' THEN 'v19'
WHEN experiment = 'F' THEN 'resend_10'
ELSE 'v6' END END experiment,
CUS_CUST_ID,
--batch_credit,
campaign_id,
execution_id,
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports
WHERE 1=1
AND notification_date >= '2022-05-06'
AND event_type IN ('shown')
and campaign_id = 'REMARKETING_MANTIKA'
)
SELECT
a.notification_date ,
a.SIT_SITE_ID,
--a.experiment_type,
a.experiment experiment,
count(DISTINCT concat(b.execution_id, b.cus_cust_id)) / NULLIF(count(DISTINCT concat(a.execution_id, a.cus_cust_id)), 0) open_rate,
count(DISTINCT concat(b.execution_id, b.cus_cust_id)) open,
count(DISTINCT concat(a.execution_id, a.cus_cust_id)) shown
FROM showns a
LEFT JOIN opens b ON concat(a.execution_id, a.cus_cust_id) = concat(b.execution_id, b.cus_cust_id)
GROUP BY 1,2,3
),
ORDERS as
(
SELECT cus_cust_id AS user_id,
-- ord_created_dttm esta sin timezone pero con horario de -4 (le sumamos 4 para corregir)
DATE_ADD(tim_day_winning_time, INTERVAL 4 HOUR) AS FECHA_ORDER,
SIT_SITE_ID as site_id,
ord_order_id AS order_id,
item_id,
--domain_id,
GMV_USD
FROM meli-bi-data.SBOX_MANTIKAMARKETING.bids_marketing_reports
WHERE 1=1
AND tim_day_winning_date >= current_date() - interval 9 week
AND tim_day_winning_date < current_date()
AND SIT_SITE_ID in ('MLA','MLM','MLB','MLC','MCO','MLU')
)
,NOTIF AS
(
SELECT
DATE_ADD(user_timestamp, INTERVAL 4 HOUR) as notif_dttm,
sit_site_id as site_id,
cus_cust_id as user_id,
campaign_id campaign,
--batch_credit,
--domain_id,
item_id_1,
item_id_2,
item_id_3,
item_id_4,
item_id_5,
batch_type,
--case when ((domain_id like ('%AUTOMOTIVE%')) or (domain_id like ('%MOTORCYCLE%')))
--then ""se va"" else ""se queda"" end
--domain,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) = '4' THEN 'resend_1'
WHEN left(execution_id,1) = '8' THEN 'resend_7'
WHEN left(execution_id,1) = '6' THEN 'resend_10'
WHEN left(execution_id,1) = '5' THEN 'resend_3'
WHEN left(execution_id,1) = '7' THEN 'resend_xsell'
WHEN left(execution_id,1) = '9' THEN 'resend_morning'
ELSE
CASE WHEN experiment = '7' then 'v17'
WHEN experiment = '9' THEN 'resend_1'
WHEN experiment IN ('B', 'D', '8') THEN 'remove_1'
WHEN experiment IN ('A', 'B') THEN 'reorder_with_redis'
WHEN experiment IN ('C', 'D') THEN 'reorder_with_postgres'
WHEN experiment = 'E' THEN 'v19'
WHEN experiment = 'F' THEN 'resend_10'
ELSE 'v6' END END experiment,
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports as A
WHERE 1= 1
AND campaign_id = 'REMARKETING_MANTIKA'
AND event_type IN ('sent') --, 'shown', 'open')
AND notification_date >= '2022-05-06'
AND notification_date < current_date()
AND sit_site_id in ('MLA','MLM','MLB','MLC','MCO','MLU')
and left(execution_id,1) = '2'
--and (case when left(execution_id,1) = '5' then 1 else 0 end ) = 1 --FILTRO RESEND
),
orders_atribuidas AS
(
SELECT order_id, fecha_order, buyer_id, site_id, campaign, batch_type, notif_2_day, gmv_usd, experiment,-- experiment_type,
FROM (
SELECT
o.order_id,
o.fecha_order,
o.user_id as buyer_id,
o.site_id,
o.gmv_usd,
n.campaign,
--n.domain domain,
-- n.batch_credit,
n.batch_type,
--n.experiment_type experiment_type,
n.experiment experiment,
n.notif_dttm notif_2_day,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR)) THEN n.notif_dttm END notif_24,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 1 HOUR)) THEN n.notif_dttm END notif_1,
--CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR) AND n.domain_id = o.domain_id) THEN n.notif_dttm END notif_24_domain,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR)
AND (o.item_id IN (n.item_id_1, n.item_id_2, n.item_id_3, n.item_id_4, n.item_id_5))) THEN n.notif_dttm END notif_24_items,
RANK() OVER (PARTITION BY o.ORDER_ID ORDER BY n.notif_dttm DESC) AS ORDEN_2
FROM orders o
LEFT JOIN notif n
ON n.user_id = o.user_id
and n.site_id = o.site_id
AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 2 DAY)
AND n.notif_dttm < o.FECHA_ORDER
AND (o.item_id IN (n.item_id_1, n.item_id_2, n.item_id_3, n.item_id_4, n.item_id_5)) --ITEMS MODIF
)
WHERE ORDEN_2 = 1
)
,total_orders_atribuidas as
(
select
site_id,
campaign,
--omain,
experiment,
--experiment_type,
-- batch_credit,
date(notif_2_day) fecha,
-- 2 Days
count(distinct case when batch_type='test' then buyer_id end) buyers_2day_test,
count(distinct case when batch_type='test' then order_id end) orders_2day_test,
sum(case when batch_type='test' then gmv_usd end) gmv_2day_test,
count(distinct case when batch_type='cg' then buyer_id end) buyers_2day_cg,
count(distinct case when batch_type='cg' then order_id end) orders_2day_cg,
sum(case when batch_type='cg' then gmv_usd end) gmv_2day_cg,
-- 24 hours
-- count(distinct case when batch_type='test' AND notif_24 IS NOT NULL then buyer_id end) buyers_test_24,
-- count(distinct case when batch_type='test' AND notif_24 IS NOT NULL then order_id end) orders_test_24,
-- sum(case when batch_type='test' AND notif_24 IS NOT NULL then gmv_usd end) gmv_test_2,
-- count(distinct case when batch_type='cg' AND notif_24 IS NOT NULL then buyer_id end) buyers_cg_2,
-- count(distinct case when batch_type='cg' AND notif_24 IS NOT NULL then order_id end) orders_cg_2,
-- sum(case when batch_type='cg' AND notif_24 IS NOT NULL then gmv_usd end) gmv_cg,
-- 24 hours same domain
from orders_atribuidas
where notif_2_day is not null -- solo orders atribuidas
group by 1,2,3,4
)
,
total_sent as
(
select
site_id,
campaign,
--domain,
experiment,
--experiment_type,
--batch_credit,
date(notif_dttm) fecha,
count(distinct case when batch_type='test' then user_id end) users_test,
count(distinct case when batch_type='cg' then user_id end) users_cg
from notif
group by 1,2,3,4
), daily_data as (
select
--date_trunc(o.fecha, MONTH) month_notif,
o.site_id sit_site_id,
--o.campaign campaign_id,
--o.domain,
o.experiment,
--o.experiment_type,
o.fecha notification_date,
date_trunc(o.fecha, week(saturday)) weeks,
user_range,
users_test/(users_test+users_cg) user_relation,
--o.batch_Credit,
users_test,
buyers_2day_test,
orders_2day_test,
gmv_2day_test,
users_cg, buyers_2day_cg, orders_2day_cg, gmv_2day_cg,
--buyers_2day_cg/users_cg cvr_cg, --Conversion Rate CG
--buyers_2day_test/NULLIF(users_test,0) -buyers_2day_cg / NULLIF(users_cg, 0) lift,
(COALESCE(buyers_2day_test - (buyers_2day_cg * users_test / NULLIF(users_cg, 0)), 0)/nullif(user_range,0))/nullif(users_test/(users_test+users_cg),0) inc_buyers,
(COALESCE(orders_2day_test - (orders_2day_cg * users_test / NULLIF(users_cg, 0)), 0)/nullif(user_range,0))/nullif(users_test/(users_test+users_cg),0) inc_orders,
--CAST(COALESCE(gmv_2day_test - (gmv_2day_cg * users_test / NULLIF(users_cg, 0)), 0) AS FLOAT64) inc_gmv,
or_.shown,
or_.open,
--or_.open/or_.shown open_rate --Open Rate
from total_orders_atribuidas o
left join total_sent n on o.site_id=n.site_id and o.campaign=n.campaign and o.fecha=n.fecha and o.experiment=n.experiment-- and o.domain=n.domain-- AND o.batch_credit = n.batch_credit
LEFT JOIN (
SELECT sit_site_id, notification_date, shown,open, experiment
FROM OpR) or_
ON o.fecha = or_.notification_date AND o.site_id = or_.sit_site_id AND o.experiment = or_.experiment
LEFT JOIN (
With mod_users AS (
SELECT
DATE(date_trunc(date_add(user_timestamp, INTERVAL 4 HOUR), DAY)) notification_date,
sit_site_id,
mod(cus_cust_id , 100) mod_100_users ,
campaign_id,
COUNT(DISTINCT cus_cust_id) cant_users
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports WHERE campaign_id = 'REMARKETING_MANTIKA' AND event_type='sent'
GROUP BY 1,2,3,4
)
SELECT notification_date,
campaign_id,
sit_site_id,
(max(mod_100_users) - min(mod_100_users) + 1)/100 user_range
FROM mod_users
WHERE cant_users> 100
GROUP BY 1,2,3
) b ON o.fecha = b.notification_date AND o.site_id = b.sit_site_id
)
Select
sit_site_id,
experiment,
""2Day Xsell Items"" attribution,
--domain,
--user_range,
--user_relation,
notification_date,
--weeks,
sum(users_test) users_test,
sum(buyers_2day_test) buyers_2day_test,
sum(orders_2day_test) orders_2day_test,
sum(users_cg) users_cg,
sum(buyers_2day_cg) buyers_2day_cg,
sum(orders_2day_cg) orders_2day_cg,
sum(inc_buyers) inc_buyers,
sum(inc_orders) inc_orders,
sum(buyers_2day_test) / NULLIF(sum(users_test),0) cvr_test,
sum(buyers_2day_cg) / NULLIF(sum(users_cg),0) cvr_cg,
(sum(buyers_2day_test) / nullif(sum(users_test),0))-(sum(buyers_2day_cg) / nullif(sum(users_cg),0)) lift,
(sum(orders_2day_test) / nullif(sum(users_test),0))-(sum(orders_2day_cg) / nullif(sum(users_cg),0)) lift_orders,
sum(shown) shown,
sum(open) open,
sum(open)/nullif(sum(shown),0) open_rate,
from daily_data
where notification_date < '2022-06-07' --FECHA MODIF
or notification_date > '2022-06-29' --FECHA MODIF
--and experiment like '%resend%'
--and users_test >= 1000
group by 1,2,3,4",Jose
Incremental Orders de Remarketing para MLB.,"site, notification date, user relation, users, buyers y orders para test y cg, incremental buyers y orders","with
ORDERS as
(
SELECT cus_cust_id AS user_id,
DATE_ADD(tim_day_winning_time, INTERVAL 4 HOUR) AS FECHA_ORDER,
SIT_SITE_ID as site_id,
ord_order_id AS order_id,
item_id,
domain_id,
GMV_USD
FROM meli-bi-data.SBOX_MANTIKAMARKETING.bids_marketing_reports
WHERE 1=1
AND tim_day_winning_date >= current_date() - 170
AND tim_day_winning_date < current_date()
AND SIT_SITE_ID in ('MLB')
)
,NOTIF AS
(
SELECT
DATE_ADD(user_timestamp, INTERVAL 4 HOUR) as notif_dttm,
sit_site_id as site_id,
cus_cust_id as user_id,
campaign_id campaign,
batch_credit,
domain_id,
item_id_1,
item_id_2,
item_id_3,
item_id_4,
item_id_5,
batch_type,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) = '4' THEN 'resend_1'
WHEN left(execution_id,1) = '6' THEN 'resend_10'
ELSE
CASE WHEN experiment = '7' then 'v17'
WHEN experiment = '9' THEN 'resend_1'
WHEN experiment IN ('B', 'D', '8') THEN 'remove_v6'
WHEN experiment IN ('A', 'B') THEN 'reorder_with_redis'
WHEN experiment IN ('C', 'D') THEN 'reorder_with_postgres'
WHEN experiment = 'E' THEN 'v19'
WHEN experiment = 'F' THEN 'resend_10'
ELSE 'v6' END END experiment,
CASE WHEN left(execution_id,1) = '2' THEN 'xsell'
WHEN left(execution_id,1) in ('4', '6', '7', '8', '5', '9') THEN 'resend'
ELSE
CASE WHEN experiment = '9' then 'resend'
WHEN experiment = 'F' THEN 'resend'
ELSE 'remarketing' END END experiment_type,
FROM meli-bi-data.SBOX_MANTIKAMARKETING.full_users_mtk_reports as A
WHERE 1= 1
AND campaign_id = 'REMARKETING_MANTIKA'
AND event_type IN ('sent')
AND notification_date >= current_date() - 170
AND notification_date < current_date()
AND sit_site_id in ('MLB')
AND left(execution_id, 1) in ('4', '6', '7', '8', '5', '9', '0')
),
orders_atribuidas AS
(
SELECT order_id, fecha_order, buyer_id, site_id, campaign, batch_type, notif_2_day, gmv_usd, experiment_type
FROM (
SELECT
o.order_id,
o.fecha_order,
o.user_id as buyer_id,
o.site_id,
o.gmv_usd,
n.campaign,
-- n.batch_credit,
n.batch_type,
-- n.xsell_divider,
n.experiment_type experiment_type,
n.notif_dttm notif_2_day,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR)) THEN n.notif_dttm END notif_24,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 1 HOUR)) THEN n.notif_dttm END notif_1,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR) AND n.domain_id = o.domain_id) THEN n.notif_dttm END notif_24_domain,
CASE WHEN (n.notif_dttm < o.FECHA_ORDER AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 24 HOUR)
AND (o.item_id IN (n.item_id_1, n.item_id_2, n.item_id_3, n.item_id_4, n.item_id_5))) THEN n.notif_dttm END notif_24_items,
RANK() OVER (PARTITION BY o.ORDER_ID ORDER BY n.notif_dttm DESC) AS ORDEN_2
FROM orders o
LEFT JOIN notif n
ON n.user_id = o.user_id
and n.site_id = o.site_id
AND n.notif_dttm >= DATE_SUB(o.FECHA_ORDER, INTERVAL 48 HOUR)
AND n.notif_dttm < o.FECHA_ORDER
)
WHERE ORDEN_2 = 1
)
,total_orders_atribuidas as
(
select
site_id,
campaign,
experiment_type,
date(notif_2_day) fecha,
-- 2 Days
count(distinct case when batch_type='test' then buyer_id end) buyers_2day_test,
count(distinct case when batch_type='test' then order_id end) orders_2day_test,
sum(case when batch_type='test' then gmv_usd end) gmv_2day_test,
count(distinct case when batch_type='cg' then buyer_id end) buyers_2day_cg,
count(distinct case when batch_type='cg' then order_id end) orders_2day_cg,
sum(case when batch_type='cg' then gmv_usd end) gmv_2day_cg,
-- 24 hours
-- count(distinct case when batch_type='test' AND notif_24 IS NOT NULL then buyer_id end) buyers_test_24,
-- count(distinct case when batch_type='test' AND notif_24 IS NOT NULL then order_id end) orders_test_24,
-- sum(case when batch_type='test' AND notif_24 IS NOT NULL then gmv_usd end) gmv_test_2,
-- count(distinct case when batch_type='cg' AND notif_24 IS NOT NULL then buyer_id end) buyers_cg_2,
-- count(distinct case when batch_type='cg' AND notif_24 IS NOT NULL then order_id end) orders_cg_2,
-- sum(case when batch_type='cg' AND notif_24 IS NOT NULL then gmv_usd end) gmv_cg,
-- 24 hours same domain