From 47fa72c7577654c5ca92d6c64143eae1edc3c977 Mon Sep 17 00:00:00 2001 From: Aysat Date: Wed, 26 Nov 2025 15:45:18 +0600 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=BE=D1=80=D0=BC=D1=83=20=D0=B8=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aysat/lifecoding/SQL1.sql | 40 +++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/aysat/lifecoding/SQL1.sql b/aysat/lifecoding/SQL1.sql index 8af1809..05df519 100644 --- a/aysat/lifecoding/SQL1.sql +++ b/aysat/lifecoding/SQL1.sql @@ -16,22 +16,30 @@ ''' with monthly_users as ( -select count(distinct(user_id)) as active_users, -date_trunc('month', date) as month -from abakhytbekuly.users -group by date_trunc('month', date) + select + count(distinct(user_id)) as active_users, + date_trunc('month', date) as month + from + abakhytbekuly.users + group by + date_trunc('month', date) ), -change as ( -select active_users, -month, -lag(active_users) over(order by month) as prev_mau -from monthly_users + change as ( + select active_users, + month, + lag(active_users) over(order by month) as prev_mau + from + monthly_users ) -select active_users, -month, -prev_mau, -100.0 * (active_users - prev_mau) / prev_mau as pct_change -- тут результат странный типа '-66.666666' -from change -where prev_mau is not null -order by month +select + active_users, + month, + prev_mau, + 100.0 * (active_users - prev_mau) / prev_mau as pct_change -- тут результат странный типа '-66.666666' +from + change +where + prev_mau is not null +order by + month