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 DROP VIEW IF EXISTS StudentsAverages;
from (
select Students.pNbr, TakenCourses.grade, avg(grade) as averageGrade CREATE VIEW StudentsAverages AS
from Students SELECT Students.firstName, Students.pNbr, TakenCourses.grade, avg(grade) as averageGrade
join TakenCourses on Students.pNbr = TakenCourses.pNbr FROM Students
group by Students.pNbr JOIN TakenCourses ON Students.pNbr = TakenCourses.pNbr
) as studentAverages GROUP BY Students.pNbr;
SELECT firstName, max(averageGrade) FROM StudentsAverages