jeffmiranda / StudentCentre

Aikido student management modules for MODX CMS
1 stars 1 forks source link

Yearly attendance sum #77

Open steve-erickson opened 8 years ago

steve-erickson commented 8 years ago

Need a sum of hours for students for each rank category - Jan 1st to Dec 31.

jeffmiranda commented 8 years ago

I used the following MySQL statement to select the data:

SELECT
    usr.username,
    clc.name,
    SUM(att.hours) AS tot

FROM sc_attendance AS att

INNER JOIN sc_scheduled_classes AS scc
ON att.scheduled_class_id = scc.id

INNER JOIN sc_classes AS cls
ON scc.class_id = cls.id

INNER JOIN sc_class_level_categories AS clc
ON cls.class_level_category_id = clc.id

INNER JOIN modx_users AS usr
ON att.student_id = usr.id

WHERE clc.id = 1
    AND att.date BETWEEN '2015-01-01' AND '2015-12-31'

GROUP BY att.student_id
ORDER BY tot DESC;

The above query produced the following files (zipped): Annual Attendance Student Attendance Totals 2015.zip