Segue o comando SQL que mapeia a quantidade de cursos concluídos e não concluídos por usuário
SELECT u.id,u.firstname,COUNT(1) AS courseenrol, COUNT( timecompleted) AS coursecompleted FROM mdl_user u LEFT JOIN mdl_course_completions c ON c.userid=u.id GROUP BY u.id,u.firstname HAVING COUNT( timecompleted) =0
O comando a seguir filtra apenas os usuários que concluíram acima de 2 cursos
SELECT u.id,u.firstname,COUNT(1) AS courseenrol, COUNT( timecompleted) AS coursecompleted FROM mdl_user u LEFT JOIN mdl_course_completions c ON c.userid=u.id GROUP BY u.id,u.firstname HAVING COUNT( timecompleted) =0 HAVING COUNT( timecompleted) > 2