Events fired twice within ten seconds
The task
The app sometimes sends the same event twice when a button is tapped quickly. The analytics team wants to know how many events to drop.
An event is a repeat when the same user fired an event with the same event_name less than 10 seconds before it. Compare each event with the user's immediately previous event of that name, not with the first event of a burst. An event that is exactly 10 seconds after the previous one is not a repeat. Events with the same occurred_at are in event_id order.
Return event_name and repeats (how many repeat events it has) for event names with at least one repeat. Sort by event_name.
Expected output
event_namerepeats- Sorted by event_name ascending.
- Checked on the sample and on 2 hidden datasets. How grading works
Tables Mobile shopping app · click a name to insert it
users360 rows in the sample
One row per user. Key: user_id.
| int | Unique id. | |
| timestamp | Sign-up time (UTC). | |
| text | Two-letter country code. | |
| text | ios, android or web. | |
| text | organic, paid, referral or partner. NULL when unknown. |
events7,616 rows in the sample
One row per tracked event. Key: event_id.
| bigint | Unique id. | |
| int | Who fired it. | |
| text | app_open, search, view_item, add_to_cart, begin_checkout, purchase or share. | |
| timestamp | When (UTC). | |
| text | Session the event belongs to. NULL for a few events sent from the background. | |
| numeric(10,2) | Order value for purchase events, NULL otherwise. |
experiment_assignments349 rows in the sample
Which variant each user saw in each experiment. Key: user_id, experiment.
| int | The user. | |
| text | new_onboarding or one_tap_checkout. | |
| text | control or treatment. | |
| timestamp | When the user was assigned (UTC). |
Related questions
- Keep the first purchase event for each web usermedium
- Repeat tickets from the same customermedium
- Current order copy when two copies share a timestamphard
- Customers with several accounts under one emaileasy
- Emails shared by accounts that disagree on countrymedium
- Find exact duplicate rows in a raw order loadeasy
Loading the editor and PostgreSQL
Loading the editor and PostgreSQL