From 5ed579b4e98acf85947efa535ef69398ad371796 Mon Sep 17 00:00:00 2001 From: Carlos Timoteo Date: Fri, 10 May 2024 14:13:46 -0400 Subject: [PATCH] Update cltv_query_template.sqlx --- templates/activation_query/cltv_query_template.sqlx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/activation_query/cltv_query_template.sqlx b/templates/activation_query/cltv_query_template.sqlx index d6082476..7e7a94a3 100644 --- a/templates/activation_query/cltv_query_template.sqlx +++ b/templates/activation_query/cltv_query_template.sqlx @@ -1,7 +1,7 @@ SELECT NTILE(10) OVER (ORDER BY a.prediction DESC) AS cltv_decile, COALESCE(b.user_id, b.user_pseudo_id) AS client_id, - TIMESTAMP_ADD(b.event_timestamp, INTERVAL 1 MICROSECOND) AS inference_date + CASE WHEN EXTRACT(MICROSECOND FROM b.event_timestamp) = 1 THEN b.event_timestamp ELSE TIMESTAMP_SUB(b.event_timestamp, INTERVAL 1 MICROSECOND) END AS inference_date FROM `${mds_project_id}.marketing_ga4_v1_${mds_dataset_suffix}.latest_event_per_user_last_72_hours` b, `{{source_table}}` a