This commit is contained in:
Imbus 2024-01-25 20:33:02 +01:00
parent 3dd7d1c576
commit 228ff2efe2

16
n.sql
View file

@ -1,7 +1,9 @@
select Students.firstName, max(averageGrade) as maxAverage
from (
select Students.pNbr, TakenCourses.grade, avg(grade) as averageGrade
from Students
join TakenCourses on Students.pNbr = TakenCourses.pNbr
group by Students.pNbr
) as studentAverages
DROP VIEW IF EXISTS StudentsAverages;
CREATE VIEW StudentsAverages AS
SELECT Students.firstName, Students.pNbr, TakenCourses.grade, avg(grade) as averageGrade
FROM Students
JOIN TakenCourses ON Students.pNbr = TakenCourses.pNbr
GROUP BY Students.pNbr;
SELECT firstName, max(averageGrade) FROM StudentsAverages