← Recursive CTEs

Daily reach: RU, web, 21 days from June 2, 2025

Level: Senior200 XP

Instructions

Consider the events (events) of users with country = 'RU' and platform = 'web' over 21 days, from June 2, 2025 to June 22, 2025 inclusive. For each day of this period, output day (type date), new_users (the number of users whose first event within the period fell on that day) and reach (the number of distinct users who had at least one event from the start of the period through that day inclusive; each user is counted once, however many days they were active). Also output days with no new users (new_users = 0). Sort by day ascending.

Hints

Each next one is more detailed and costs more

Log in to open hints

Query

Result

Click Run to see the query result, or Check to submit your solution.

Dataset schema

events.user_id (0…N) ↔ users.id (1…1)purchases.user_id (0…N) ↔ users.id (1…1)eventsPKidintegerFKuser_idintegerpurchasesPKidintegerFKuser_idintegerusersPKidinteger
Exactly oneZero or oneZero or more
Table relationships
  • N:1Many-to-oneevents.user_id → users.id
  • N:1Many-to-onepurchases.user_id → users.id

Table data

PostgreSQL

Select a table in the diagram or list to view its rows.

Dataset schema