Suppose your have data like below table and you want to know rank of students.
You will simple put following formula in D2
=RANK(C2,C2:C100)
But what if you are asked to produce rank of students within each school. Hence, every school's rank will start with 1..
Put following formula in D2 for that case for Descending order ranking. (For ascending order, replace ">" with "<" without quote marks)
=SUMPRODUCT((B$2:B$100=B2)*(C$2:C$100>C2))+1
OR
=COUNTIFS(B$2:B$100,B2,C$2:C$100,">"&C2)+1