1pico=# select
2 count(DISTINCT CASE
3 WHEN user_id IS NOT NULL
4 THEN 1
5 count | month
6-------+------------------------
7 26 | 2024-10-01 00:00:00+00
8 44 | 2024-09-01 00:00:00+00
9 65 | 2024-08-01 00:00:00+00
10 56 | 2024-07-01 00:00:00+00
11 42 | 2024-06-01 00:00:00+00
12 29 | 2024-05-01 00:00:00+00
13 36 | 2024-04-01 00:00:00+00
14 49 | 2024-03-01 00:00:00+00
15 29 | 2024-02-01 00:00:00+00
16 21 | 2024-01-01 00:00:00+00
17 5 | 2023-12-01 00:00:00+00
18 22 | 2023-11-01 00:00:00+00
19 31 | 2023-10-01 00:00:00+00
20 38 | 2023-09-01 00:00:00+00
21 25 | 2023-08-01 00:00:00+00
22 43 | 2023-07-01 00:00:00+00
23 47 | 2023-06-01 00:00:00+00
24 29 | 2023-05-01 00:00:00+00
25 33 | 2023-04-01 00:00:00+00
26 39 | 2023-03-01 00:00:00+00
27 41 | 2023-02-01 00:00:00+00
28 49 | 2023-01-01 00:00:00+00
29 52 | 2022-12-01 00:00:00+00
30 53 | 2022-11-01 00:00:00+00
31 58 | 2022-10-01 00:00:00+00
32 62 | 2022-09-01 00:00:00+00
33 591 | 2022-08-01 00:00:00+00