次の3つのテーブルがあります。難易度ごとに学生が登録したコースの数と、登録したコースの総数を取得する単一のクエリを作成したいと思います。登録していない学生もリストに記載する必要があります。
Students Table:
Student ID Student Name
1 Alice
2 Bob
3 Charlie
4 David
Courses Table:
Course ID Course Name Difficulty Level
1 Arithmetic 1
2 Advanced Calculus 3
3 Algebra 2
4 Trignometry 2
Enrollment Table:
Enrollment ID Student ID Course ID
1 1 1
2 1 3
3 1 4
4 2 2
5 2 3
6 2 4
7 3 3
予想される出力は次のとおりです。
Output:
Student ID Student Name Total Courses Courses with Courses with Courses with
Enrolled In Difficulty Level 1 Difficulty Level 2 Difficulty Level 3
1 Alice 3 1 2 0
2 Bob 3 0 2 1
3 Charlie 1 0 1 0
4 David 0 0 0 0
これについて何か助けていただければ幸いです。いくつかのクエリを試してみましたが、すべての学生を一覧表示する 1 つのクエリにたどり着くのは難しいと感じています。