These are various SQL statements built to extract data from Moodle.  They are listed here to reduct the time to build special reports.

List of enrolled students

SELECT, u.username, u.firstname, u.lastname,
       , ue.enrolid,e.courseid,
                 c.category, c.shortname,c.fullname,
        AS catname
            FROM mdl_user AS u
                 JOIN mdl_user_enrolments AS ue ON (
                 JOIN mdl_enrol AS e ON (
                 JOIN mdl_course AS c ON (
                 JOIN mdl_course_categories AS cc ON (
           WHERE u.deleted=0
           ORDER BY c.category,c.shortname,u.lastname,u.firstname