I am new to Moodle. I try to get the total number of enrolled students in a particular course. I am using the below query I got from community
SELECT c.fullname AS 'Course Name'
,COUNT(u.username) AS '# of Users'
FROM mdl_role_assignments AS r
JOIN mdl_user AS u on r.userid = u.id
JOIN mdl_role AS rn on r.roleid = rn.id
JOIN mdl_context AS ctx on r.contextid = ctx.id
JOIN mdl_course AS c on ctx.instanceid = c.id
WHERE rn.shortname = 'student' and c.idnumber like "%202110%"
GROUP BY c.fullname;
But the numbers I got differs greatly from the front end admin site. Where am I going wrong?