SELECT s1.student_id, s1.student_name, s2.subject_name, COUNT(e.subject_name) AS attended_examsFROM Students s1 JOIN Subjects s2 LEFT JOIN Examinations eON s1.student_id=e.student_id AND s2.subject_name=e.subject_nameGROUP BY s1.student_id, s2.subject_name;