← Retention, funnels, cohorts

Return and repeat in 14 days: Feb 2025, RU

Level: Senior200 XP

Instructions

A user's first purchase is their earliest record in purchases (over the whole history). Take users from the country 'RU' whose first purchase (p1) fell in February 2025 (from February 1, 2025 to February 28, 2025 inclusive). A user returned if they have an 'open' event strictly later than p1 and no later than p1 + 14 days (p1 + interval '14 days'); a user made a repeat purchase if purchases has a purchase of theirs strictly later than p1 and no later than p1 + 14 days. For each platform (users.platform), output platform, buyers (the number of such users), returned and repurchased (the number of users who returned and who made a repeat purchase; each user once), returned_pct and repurchased_pct (these numbers as a percentage of buyers, × 100, rounded to 1 decimal place). Sort by platform.

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