Alteryx wants to identify the most engaged users across account regions. Using activity recorded in its user event pipeline, write a PostgreSQL query that finds the top three active users in each region over the 30-day period ending on 2025-02-15.
Requirements
- Join users to account details and user events.
- Include only events from 2025-01-17 through 2025-02-15, inclusive. Ignore events with a NULL timestamp and accounts without a region.
- Calculate each user's event count, number of active calendar days, and distinct event types.
- Rank users within each region by event count descending, active days descending, and user ID ascending as the deterministic tie-breaker.
- Return no more than three users per region, with the ranking included in the output.