I'm sure it's not impossible too, cause it exists somewhere in the moodle core !
Actually I am looking for quite the same query used to retrieve grades while enrolling/re-enrolling users.
I was doing some research in moodle libs in the enrol and gradebook folders, but I've found noting yet.
The data is there in the mdl_grade_grades_history and mdl_grade_items_history, I just don't understand how it works for now.
How the grade data is moved from one table to another while unenrollment, and where is the link between enrol and user_enrolments with unenrolled users.
The status for unenrolled user don't help really but could be an interesting filter.