dblabs/p.sql
2024-01-25 21:17:11 +01:00

10 lines
No EOL
337 B
SQL

DROP VIEW IF EXISTS StudentsCredits;
CREATE VIEW StudentsCredits AS
SELECT Students.firstName, 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;