https://leetcode.com/problems/students-and-examinations/description/
MySQL, Oracle
SELECT s.student_id, s.student_name, sub.subject_name,
COALESCE(COUNT(e.subject_name), 0) AS attended_exams
FROM Students s
CROSS JOIN Subjects sub
LEFT JOIN Examinations e
ON s.student_id = e.student_id AND sub.subject_name = e.subject_name
GROUP BY s.student_id, s.student_name, sub.subject_name
ORDER BY s.student_id, sub.subject_name;
답은 동일.
Cross 조인하고 Left 조인을 동시에 사용한다.
COALESCE 을 이용해서 시험을 보지 않은 경우에도 0 점을 받아올수있게 한다.
