Premium problem85. Reactivated After 90 Days

Medium Locked

events(user_id, event_at)

A reactivation is an event that lands at least 90 full days after that user's previous event. Return each user's first reactivation that happened in 2026.

Return user_id, reactivated_at and inactive_days, the whole days since the previous event, ordered by user_id.

A user's very first event is not a reactivation, since there is no gap before it. And a user who reactivates twice in 2026 appears once.

Tables

events

user_id  event_at
-------  -------------------
10       2026-01-01 00:00:00
10       2026-05-01 00:00:00
10       2026-09-01 00:00:00
11       2026-01-01 00:00:00
11       2026-03-31 00:00:00
12       2025-10-01 00:00:00
12       2026-02-01 00:00:00
13       2026-06-01 00:00:00

Expected result

user_id  reactivated_at       inactive_days
-------  -------------------  -------------
10       2026-05-01 00:00:00  120
12       2026-02-01 00:00:00  123

Premium problem

This one's part of Premium. Unlock the full MySQL track plus every other premium problem on the site.

Write one SELECT query