Among the students registered for the course "Psychology". what % of them have a GPA > 3?
Student:
student_id* | student_name | student_gender
Course:
course_id* | course_name | course_type
Student_course_grade:
student_id | course_id | grade
Please note :
- Grade field in Student_course_grade table is a number in (5,4,3,2,1) instead of a letter grade like (A,B,C,D,E)
- For a student who has registered for a course and has not completed it yet, the grade will be null.
- GPA= Grade Point Average ( average of all grades scored by the student)
Ans:
Select 100*count(case when avg(b.grade) >3 and b.course_name = ‘Psychology’ then 1 else 0)/count(Case when b.course_name = ‘Psychology’ then 1 else O)
From course a left join
student_course_grade b
On a.courseid=b.courseid Join
student c
On c.studentid=b.student.id
Where b.grade is NULL