Problem: 1280. 学生们参加各科测试的次数
👨🏫 参考题解
join
等价于inner join
,不用关联条件的join
等价于cross join
Code
select stu.student_id,stu.student_name, sub.subject_name,count(e.subject_name) attended_exams
from Students stu
join Subjects sub
left join Examinations e
on e.student_id = stu.student_id
And e.subject_name = sub.subject_name
group bystu.student_id, sub.subject_name
order bystu.student_id,sub.subject_name