Write a query utilizing window functions such as ROW_NUMBER or DENSE_RANK to identify the top three active users per region over the last quarter.
Treat users with is_active = true as active. Count each user's activity during the previous calendar quarter based on activity_at.
region, user_id, user_name, activity_count, and activity_rank.region, activity_rank, and user_id.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| user_name | VARCHAR(100) | User display name |
| region | VARCHAR(50) | User's geographic region |
| is_active | BOOLEAN | Whether the user is currently active |
| Column | Type | Description |
|---|---|---|
| activity_idPK | INT | Unique activity identifier |
| user_id | INT | User associated with the activity |
| activity_at | TIMESTAMP | Timestamp when the activity occurred |
| activity_type | VARCHAR(50) | Type of user activity |