Hey, your sentence isn't grammatically correct. That's ok though, try your best.
You could say the following instead:
He's upset because he didn't pass the exam. After finding out, he got even more upset when he compared his grade to that of the number one (or top) student in his class.