A query that count the course students

A query that count the course students

by Denia H. -
Number of replies: 0


Hello,

we wrote a query that count all the courses participants in the same category which we open every year.

Till now it worked fine till something got wrong & it shoes a few participants more then it should (like in the course).

Attach the query

will be tankful to hear what got wrong

Thank you

Denia



SELECT count(en.courseid) as numstud , 

course_cat.name as category, 

c.fullname as course

FROM {course} as c 

JOIN {course_categories} as course_cat on course_cat.id = c.category

left JOIN (select en.courseid from {enrol} as en

JOIN {user_enrolments} as e on en.id = e.enrolid

JOIN  {user} as u on e.userid = u.id 

where  u.deleted = 0 and u.suspended = 0 ) en on c.id = en.courseid

WHERE   course_cat.id=16

group by course_cat.id, course_cat.name, c.id, c.fullname, c.startdate

order by c.startdate

Average of ratings: -