Write a SQL query to identify the top 3 most engaged students per institution using window functions. Use the provided institutions, students, and engagement_events tables. Define engagement as the sum of engagement_points, treating missing points as zero.
Output
- One row per qualifying student, with
institution_id, institution_name, student_id, student_name, engagement_score, and engagement_rank
- Include up to three students per institution, ranked by score descending, with lower
student_id first for ties
- Order by
institution_id, then engagement_rank