My customer asks me if I had a report that lists the number of assignments in each course. I thought, well, not really, but I think I could come up with some SQL that would do that.
No details - by omitting details, we can create a nice summary report. A report like this
courseid - course name - count of assignments in course
SQL to create report
SELECT DISTINCT a.course, c.fullname as coursename, tempTable.count_of_assignmentsNice.
FROM mdl_assignment a
INNER JOIN
(
SELECT course, count(*) as count_of_assignments
FROM mdl_assignment
GROUP BY course
)
tempTable
ON a.course = tempTable.course
INNER JOIN mdl_course c on c.id = a.course
ORDER BY coursename
No comments:
Post a Comment