Поправил форму и добавил описание
This commit is contained in:
+24
-16
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user