Write a SQL query using window functions to rank users by engagement within each cohort for NeuroFlow reporting.
Use the provided users and engagement_events data. Include users with no matching events, treat their engagement as zero, and allow tied users to share a rank.
user_id, cohort, total_engagement, and engagement_rank.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| display_name | VARCHAR(100) | User display name |
| cohort | VARCHAR(30) | User reporting cohort |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique engagement event identifier |
| user_id | INT | User associated with the event |
| engagement_score | INT | Engagement points recorded for the event |