10 lines
341 B
MySQL
10 lines
341 B
MySQL
|
DROP VIEW IF EXISTS StudentsCredits;
|
||
|
|
||
|
CREATE VIEW StudentsCredits AS
|
||
|
SELECT Students.pNbr, sum(credits) as totalCredits
|
||
|
FROM Students
|
||
|
JOIN TakenCourses ON Students.pNbr = TakenCourses.pNbr
|
||
|
JOIN Courses ON TakenCourses.courseCode = Courses.courseCode
|
||
|
GROUP BY Students.pNbr;
|
||
|
|
||
|
SELECT * FROM StudentsCredits ORDER BY totalCredits DESC;
|