Sounds like a challenge you'd need a Student Information System or archiving tool for. Not exactly what Moodle was developed for, I think. If it's just the grades you're interested in (and not the actual work they did in course activities), that's where you may find answers.
Teaching with Moodle
admin strategy to track students across multiple years
This discussion has been locked so you can no longer reply to it.