snap_events(user_id, event_type, event_at) and users(user_id, age_bucket)
For September 2026, return for each age bucket what percentage of its events were sends and what percentage were opens. Other event types are ignored entirely, including in the denominator.
Return age_bucket, send_pct and open_pct rounded to two decimals, ordered
by age_bucket.
The two percentages add to 100 within a bucket, because the denominator is sends plus opens rather than all events.
Tables
snap_events
user_id event_type event_at
------- ---------- -------------------
1 send 2026-09-01 10:00:00
1 send 2026-09-02 10:00:00
1 open 2026-09-03 10:00:00
2 open 2026-09-04 10:00:00
2 send 2026-09-04 11:00:00
1 screenshot 2026-09-05 10:00:00
3 send 2026-09-06 10:00:00
4 open 2026-09-07 10:00:00
... 1 more row(s)
users
user_id age_bucket
------- ----------
1 18-24
2 18-24
3 25-34
4 25-34
Expected result
age_bucket send_pct open_pct
---------- -------- --------
18-24 60.00 40.00
25-34 50.00 50.00