A school's "rating" is merely an average of the quality of education students there receive. It's entirely possible to "get lucky" and have an exceptional teacher or participate in an optional extracurricular that helps them learn more than their peers. And, of course, there's also the chance that the student did well despite going to a bad school, by self-studying.