Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Student Exam Attendance by Subject

Medium Joins

Return every combination of student and subject together with how many times that student attended that subject's exam (0 if never). Order by student id, then subject name.

Table schema

Students(id INT PRIMARY KEY, name VARCHAR(50))
Subjects(name VARCHAR(50) PRIMARY KEY)
Exams(student_id INT, subject VARCHAR(50))

Sample data

Students:
id | name
1 | Alice
2 | Bob

Subjects:
name
Math
Physics

Exams:
student_id | subject
1 | Math
1 | Math
2 | Physics

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.