Created
March 30, 2024 17:11
-
-
Save mlivingston40/bc0bb591fedd28153852858baa1da860 to your computer and use it in GitHub Desktop.
find all exams by student by subjects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Write your PostgreSQL query statement below | |
select | |
s.student_id, | |
s.student_name, | |
j.subject_name, | |
sum(case when e.subject_name is null then 0 else 1 end) as attended_exams | |
from | |
Students s | |
Cross join Subjects j | |
left join Examinations e | |
on e.student_id = s.student_id and e.subject_name = j.subject_name | |
group by 1,2,3 | |
order by 1,3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment