notification_prompts(user_id, prompted_at) and
settings_events(user_id, event_type, event_at)
For prompts shown in September 2026, return how many prompts there were, how many led to the user enabling notifications within 24 hours, and the conversion rate.
The enabling event has event_type = 'notifications_enabled' and must fall in
[prompted_at, prompted_at + 24 hours]. Each prompt is judged on its own, so one
user prompted twice contributes two prompts.
Return prompt_count, converted_prompts and conversion_pct rounded to two
decimals.
Joining the two tables directly double-counts: one enable event inside two prompts' windows would turn one conversion into two.
Tables
notification_prompts
user_id prompted_at
------- -------------------
10 2026-09-01 09:00:00
10 2026-09-01 20:00:00
11 2026-09-02 09:00:00
12 2026-09-03 09:00:00
13 2026-08-31 09:00:00
settings_events
user_id event_type event_at
------- --------------------- -------------------
10 notifications_enabled 2026-09-02 08:00:00
11 notifications_enabled 2026-09-03 10:00:00
12 notifications_enabled 2026-09-02 09:00:00
12 theme_changed 2026-09-03 10:00:00
13 notifications_enabled 2026-08-31 10:00:00
Expected result
prompt_count converted_prompts conversion_pct
------------ ----------------- --------------
4 2 50.00