LeetCode - 1280. Students and Examinations (MySQL)

조민수·2024년 6월 8일
0

LeetCode

목록 보기
24/61

Easy, SQL - LEFT JOIN

RunTime : 970 ms


문제

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.

The result format is in the following example.


풀이

  • Easy보단 Medium에 가깝지 않나...
  • 3개의 테이블을 다중 조인하고 그 중, LEFT JOIN을 통해 없는 결과값에 대해 0을 가져와야 했다.
SELECT S.student_id, S.student_name, U.subject_name, COUNT(E.student_id) AS attended_exams
FROM Students AS S JOIN Subjects AS U LEFT JOIN Examinations AS E
ON S.student_id = E.student_id AND U.subject_name = E.subject_name
GROUP BY 1, 3
ORDER BY 1, 3
profile
사람을 좋아하는 Front-End 개발자

1개의 댓글

comment-user-thumbnail
2024년 7월 24일

Prepare for the https://www.dumpstool.com/SY0-701-exam.html Exam and boost your cybersecurity career! Our comprehensive study guides and practice exams provide in-depth coverage of all exam objectives, from threat management to cryptography. Whether you're a beginner or an experienced professional, our study materials will equip you with the knowledge and skills to ace the exam. Join our community of successful IT professionals and take the next step in securing your future. Start your journey to becoming CompTIA Security+ certified today!

답글 달기