20 lines
345 B
SQL
20 lines
345 B
SQL
with cte1 as (
|
|
select count(distinct(user_id)) as mau,
|
|
date_trunc('month', date) as month
|
|
from abakhytbekuly.users
|
|
group by date_trunc('month', date)
|
|
),
|
|
cte2 as (
|
|
select mau,
|
|
month,
|
|
lag(mau) over(order by month) as prev_mau
|
|
from cte1
|
|
)
|
|
select mau,
|
|
month,
|
|
prev_mau,
|
|
100.0 * (mau - prev_mau) / prev_mau as pct_change
|
|
from cte2
|
|
order by month
|
|
|