Take a look at the query I did for this over in the ad-hoc reports area. It will show you how to do groups and memberships. You can just add in the roles which you already have.
https://docs.moodle.org/27/en/ad-hoc_contributed_reports#Groups_in_course_with_member_list