SQL Query to list Absentees

SQL Query to list Absentees

by Aalishan Moosavi -
Number of replies: 2

Hi ,

  Can you please help me code SQL query to list all students and their contact number who are absent from class.

Thanks

Aali

Average of ratings: -
In reply to Aalishan Moosavi

Re: SQL Query to list Absentees

by Cristian Blanquer -

Hi Aalishan!

I don't know what version of moodle are you using, but i've code a query that gets the info that you are looking for.

The query:

SELECT CONCAT(u.lastname, ' ', u.firstname) as Student,
u.phone1, c.fullname as Course, FROM_UNIXTIME(ul.timeaccess) as 'Last access'
FROM moodle.mdl_user_lastaccess ul
inner join mdl_user u ON u.id = ul.userid
inner join mdl_course c ON ul.courseid = c.id
where TIMESTAMPDIFF(MONTH, FROM_UNIXTIME(ul.timeaccess),(NOW())) > 0 -- Put the Months diff
order by Student, Course

Best regards

Average of ratings: Useful (1)