From a28066a83e110760896f68f6c7f5c577a4461ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=96=D1=83=D0=BB=D1=8C=20=D0=9A=D0=B8=D1=80=D0=B8=D0=BB?= =?UTF-8?q?=D0=BB?= <118897479+KirillZhul@users.noreply.github.com> Date: Mon, 29 May 2023 13:21:34 +0300 Subject: [PATCH] Update datamart_query.sql --- datamart_query.sql | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/datamart_query.sql b/datamart_query.sql index 8b13789..1a5053d 100644 --- a/datamart_query.sql +++ b/datamart_query.sql @@ -1 +1,9 @@ - +INCERT INTO analysis.dm_rfm_segments (user_id, recency, frequency, monetary_value) +SELECT u.id, + r.recency, + f.frequency, + m.monetary_value +FROM analysis.users u +LEFT JOIN analysis.tmp_rfm_recency r ON u.id = r.user_id +LEFT JOIN analysis.tmp_rfm_frequency f ON u.id = f.user_id +LEFT JOIN analysis.tmp_rfm_monetary_value m ON u.id = m.user_id;