Loading problem...
An academic analytics platform tracks exam marks for students across departments. Program heads want a normalized way to compare each student against peers in the same department.
Table: Students
Task: For every student row, compute a department-relative rank percentage using: percentage = (rank - 1) * 100 / (department_size - 1)
Ranking behavior:
Edge behavior:
Output requirements:
Supported submission environments:
Students:
| student_id | department_id | mark |
|------------|---------------|------|
| 101 | 10 | 95 |
| 102 | 10 | 88 |
| 103 | 10 | 70 |
| 201 | 20 | 90 |
| 202 | 20 | 90 |[
{"student_id":101,"department_id":10,"percentage":0.0},
{"student_id":102,"department_id":10,"percentage":50.0},
{"student_id":103,"department_id":10,"percentage":100.0},
{"student_id":201,"department_id":20,"percentage":0.0},
{"student_id":202,"department_id":20,"percentage":0.0}
]Department 10 has three students with ranks 1, 2, 3 mapping to 0, 50, and 100. Department 20 has a tie at the top, so both students receive rank 1 and percentage 0.
Students:
| student_id | department_id | mark |
|------------|---------------|------|
| 301 | 30 | 77 |[
{"student_id":301,"department_id":30,"percentage":0.0}
]A single-student department always yields 0.00 because the denominator department_size - 1 is zero.
Students:
| student_id | department_id | mark |
|------------|---------------|------|
| 401 | 40 | 92 |
| 402 | 40 | 85 |
| 403 | 40 | 85 |
| 404 | 40 | 60 |[
{"student_id":401,"department_id":40,"percentage":0.0},
{"student_id":402,"department_id":40,"percentage":33.33},
{"student_id":403,"department_id":40,"percentage":33.33},
{"student_id":404,"department_id":40,"percentage":100.0}
]Marks 85 and 85 share rank 2. With four students, percentage for rank 2 is (2 - 1) * 100 / 3 = 33.33.
Constraints