You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Write your MySQL query statement belowselects.student_id, s.student_name, s2.subject_name, count(e.student_id) as attended_exams
from Students s
join Subjects s2
left join Examinations e
ons.student_id=e.student_idands2.subject_name=e.subject_namegroup bys.student_id, s2.subject_nameorder bys.student_id, s2.subject_name
SQL Solution v2
# Write your MySQL query statement below、selectt1.student_id, t1.student_name, t1.subject_name, ifnull(t2.attended_exams,0) as attended_exams
from (selects1.student_id, s1.student_name, s2.subject_namefrom Students s1 join Subjects s2 order bys1.student_id, s2.subject_name)
as t1
left join
(select student_id, subject_name, count(*) as attended_exams
from Examinations group by student_id, subject_name) t2
ont1.student_id=t2.student_idandt1.subject_name=t2.subject_nameorder byt1.student_id, t1.subject_name