27. Students and Examinations
https://leetcode.com/problems/students-and-examinations/
Write a solution to find the number of times each student attended each exam. Return the result table ordered by student_id and subject_name.
select s.student_id, student_name, j.subject_name , count(e.student_id) attended_exams from students s cross join subjects j left join examinations e on s.student_id=e.student_id and j.subject_name=e.subject_name group by 1,2,3 order by 1
Cross join의 개념 숙지하기! 처음 Cross join없이 join만 했을 때에도 동작했던 오류가 발생했었음.. 그래도 cross join으로 합친 후에 count(e.student_id)로 정확한 수를 카운트하기! count() 내의 컬럼을 다르게 하면 답이 달라질 수 있음!