diff --git a/o.sql b/o.sql new file mode 100644 index 0000000..1d82c19 --- /dev/null +++ b/o.sql @@ -0,0 +1,10 @@ +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; \ No newline at end of file