I have cobbled together a summary query to help me quickly look for students that need some encouragement to complete their assigned courses.
I am stymied by two issues.
1. My Sum statement does not product an error, but it also does not produce any results. My workaround is to export to Excel and do the math there, but I would like to learn how to correctly create a SUM statement.
2. My SQL Query is off-here and there because when an active employee is moved to a new job position their cohort membership is removed. The filter current enrolments is not reading the adjusted cohort membership.
The course participation's enrollments are correct, but my SQL Queries are always a little overstated here and there.
Is there a way I can correct the issues I am having with this query?
SELECT DISTINCT
CONCAT(u.firstname, ' ', u.lastname) AS Name,
COUNT(p.timeenrolled) as 'Assigned',
COUNT(p.timecompleted) AS 'TotalCompletions',
SUM(('TotalCompletions' / 'Assigned' )*100) As PercentComplete
FROM prefix_course_completions AS p
JOIN prefix_course AS c ON p.course = c.id AND c.visible = 1
JOIN prefix_user AS u ON p.userid = u.id
AND u.deleted = 0 AND u.suspended = 0
%%FILTER_COURSES:id%%
%%FILTER_COURSEENROLLEDSTUDENTS%%
GROUP BY p.userid
ORDER BY Name
Kind Regards