Enrolment method count during last 7 days

Enrolment method count during last 7 days

by Stuart Milligan -
Number of replies: 2

Hi all,

I'm a first-time poster so apologies if I've posted in the wrong place or this questions has been asked before (I've had a look but couldn't find anything)


I would like to write an SQL report that counts the number of enrolment methods by course. What I have so far is:


SELECT c.fullname AS 'Course',

       e.enrol AS 'Method',

       Count(e.enrol) AS 'Count'

  FROM {user_enrolments} AS ue

    JOIN {enrol} AS e ON e.id = ue.enrolid

    JOIN {course} AS c ON c.id = e.courseid

  GROUP BY c.fullname, e.enrol


However I would like the count to be for course enrolments started within the last 7 days.


Could anyone please give me a little help? I'd really appreciate it


Thanks


Stuart

Average of ratings: -
In reply to Stuart Milligan

Re: Enrolment method count during last 7 days

by Randy Thornton -
Picture of Documentation writers
Stuart,

In the user_enrolments table there are two columns, timecreated and timemodified.
The created one is when the enrollment was first made (by whatever method). If it gets changed or edited after that for some reason, then the modified date holds that.

You can use either one of those dates and add a WHERE clause to check that those dates are within the last seven days. There's a similar snippet of code you can use in this query https://docs.moodle.org/38/en/ad-hoc_contributed_reports#Users_loggedin_within_the_last_7_days over in the query repository page.
Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Enrolment method count during last 7 days

by Stuart Milligan -

Thanks Randy, thats a great help!

Really appreciate it!