Just figured out problem #1. Now the big issue is calculating this only between records of the same student.
Have you used a self join for this calculation?
Include the student in the self join and use the second table occurence in your calculation.
If this doesn't make any sense, please explain your problem in more detail so as to provide more precise pointers.