Write a SQL query to find the top 5 departments by student retention rate using window functions for UNC Chapel Hill.
Use the provided student, department, and enrollment records. Define retention as enrollment in both 2023-Fall and 2024-Fall. Exclude departments without students in the starting term.
Output
- One row per department, limited to the five highest retention rates.
- Columns:
department_id, department_name, starting_students, retained_students, retention_rate, and department_rank.
- Sort by retention rate descending, then department ID ascending for ties.