Thanks, this is what I'm doing currently. However, we are moving from self-hosted to hosted and I probably won't have the same level of DB access in the future. But for now, some queries if others might benefit from them also:
/* Courses sorted by their modified date, date in a human readable form */
SELECT cou.id, cat.name, cou.fullname, cou.shortname, cou.summary,
FROM_UNIXTIME(cou.timecreated, '%Y-%m-%d') AS created, FROM_UNIXTIME(cou.timemodified, '%Y-%m-%d') AS modified
FROM mdl_course AS cou, mdl_course_categories AS cat
WHERE cou.category = cat.id ORDER BY modified ASC;
/* Return the number of enrolled participants for each course */
SELECT e.courseid, COUNT(ue.id) FROM mdl_user_enrolments AS ue, mdl_enrol AS e WHERE ue.enrolid = e.id GROUP BY e.courseid;
The latter won't give the empty ones but it's easy to do a "NOT IN" query based on these courseids.