I am looking for some help with the SQL code to produce a report that shows the number of enrollments per enrollment method in each course. I am currently using the Course Enrollment report from the repository and would just like to add the columns for Manual Enrollments, Self Enrollment and Paypal Enrollments.
Here is what I am using right now:
SELECT concat('<a target="_new" href="%%WWWROOT%%/course/view.php?id=',course.id,'">',course.fullname,'</a>') AS Course
,concat('<a target="_new" href="%%WWWROOT%%/user/index.php?contextid=',context.id,'">Show users</a>') AS Users
, COUNT(course.id) AS Students
FROM prefix_role_assignments AS asg
JOIN prefix_context AS context ON asg.contextid = context.id AND context.contextlevel = 50
JOIN prefix_user AS USER ON USER.id = asg.userid
JOIN prefix_course AS course ON context.instanceid = course.id
WHERE asg.roleid = 5
GROUP BY course.id
ORDER BY COUNT(course.id) DESC
Can anyone assist or get me started in the right direction?