pico=# select count(distinct user_id), date_trunc('month', updated_at) as month from projects group by month order by month DESC; count | month -------+--------------------- 20 | 2024-10-01 00:00:00 21 | 2024-09-01 00:00:00 22 | 2024-08-01 00:00:00 24 | 2024-07-01 00:00:00 13 | 2024-06-01 00:00:00 19 | 2024-05-01 00:00:00 29 | 2024-04-01 00:00:00 40 | 2024-03-01 00:00:00 34 | 2024-02-01 00:00:00 6 | 2024-01-01 00:00:00 2 | 2023-11-01 00:00:00 1 | 2023-10-01 00:00:00 5 | 2023-09-01 00:00:00 1 | 2023-08-01 00:00:00 select count(distinct user_id), date_trunc('month', updated_at) as month from posts group by month order by month DESC; count | month -------+------------------------ 26 | 2024-10-01 00:00:00+00 44 | 2024-09-01 00:00:00+00 65 | 2024-08-01 00:00:00+00 56 | 2024-07-01 00:00:00+00 42 | 2024-06-01 00:00:00+00 29 | 2024-05-01 00:00:00+00 36 | 2024-04-01 00:00:00+00 49 | 2024-03-01 00:00:00+00 29 | 2024-02-01 00:00:00+00 21 | 2024-01-01 00:00:00+00 5 | 2023-12-01 00:00:00+00 22 | 2023-11-01 00:00:00+00 31 | 2023-10-01 00:00:00+00 38 | 2023-09-01 00:00:00+00 25 | 2023-08-01 00:00:00+00 43 | 2023-07-01 00:00:00+00 47 | 2023-06-01 00:00:00+00 29 | 2023-05-01 00:00:00+00 33 | 2023-04-01 00:00:00+00 39 | 2023-03-01 00:00:00+00 41 | 2023-02-01 00:00:00+00 49 | 2023-01-01 00:00:00+00 52 | 2022-12-01 00:00:00+00 53 | 2022-11-01 00:00:00+00 58 | 2022-10-01 00:00:00+00 62 | 2022-09-01 00:00:00+00 591 | 2022-08-01 00:00:00+00 1 | 2022-05-01 00:00:00+00 1 | 2022-04-01 00:00:00+00 1 | 2022-03-01 00:00:00+00