From f5d7fa8df50280b1b8b377e0c53d6c874937d348 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Thu, 25 Jan 2024 21:05:45 +0100 Subject: [PATCH] O fixed --- o.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 o.sql 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