Also, take a look at some of the queries over in the Ad-hoc queries which deal with roles and enrollments. There are several, such as https://docs.moodle.org/32/en/ad-hoc_contributed_reports#LIST_of_all_site_USERS_by_COURSE_enrollment_.28Moodle_2.x.29
Configurable reports block (plugin)
Table relationship advice only :)
This discussion has been locked so you can no longer reply to it.