Fixed n
This commit is contained in:
parent
3dd7d1c576
commit
228ff2efe2
1 changed files with 9 additions and 7 deletions
16
n.sql
16
n.sql
|
@ -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
|
Loading…
Reference in a new issue