People(id, family, given, birthday, ...)
Courses(id, subject, term, ...)
Subjects(id, code, title, ...)
CourseEnrolments(student, course, grade, mark, ...)
create view EnrolmentCounts as
select s.code, c.term, count(e.student) as nstudes
from Courses c join Subjects s on c.subject=s.id
join CourseEnrolments e on e.course = c.id
group by s.code, c.term;
|