Write a SQL query using window functions to rank users by weekly activity within each cohort.
Use the users and user_activity tables. Include only users assigned to a cohort and activity records with a matching user.
cohort_week, activity_week, user_id, weekly_activity, and activity_rank.cohort_week, activity_week, activity_rank, and user_id.| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique user identifier |
| user_name | VARCHAR(100) | User display name |
| cohort_week | DATE | Monday date identifying the user's cohort week |
| Column | Type | Description |
|---|---|---|
| activity_idPK | INTEGER | Unique activity record identifier |
| user_id | INTEGER | User associated with the activity record |
| activity_at | TIMESTAMP | Timestamp when activity occurred |
| activity_count | INTEGER | Number of activity units recorded |