Skip to content

2346. Compute the Rank as a Percentage 👎

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
SELECT
  student_id,
  department_id,
  ROUND(
    100 * PERCENT_RANK() OVER(
      PARTITION BY department_id
      ORDER BY mark DESC
    ),
    2
  ) AS percentage
FROM Students;