SQL Window Functions

# rn = 1, 2, 3, 4 ordered by grades each row gets a new line number

Select *, ROW_NUMBER() OVER(ORDER BY Grades) rn

# rk = 1, 2, 3, 1, 2, 3 Local student rank per grades

SELECT *, RANK() OVER(PARTITION BY Student ORDER BY Grades) rk

# rk = 1, 2, 3, 3, 4, 4, 5, 6 -- Global rank on grades

SELECT *, RANK() OVER(ORDER BY Grades) rk

https://www.sqlshack.com/overview-of-sql-rank-functions/