dblabs/p.sql

12 lines
433 B
MySQL
Raw Normal View History

2024-01-25 21:55:48 +01:00
--Same question as in question o) but with names instead of person numbers.
2024-01-25 21:17:11 +01:00
DROP VIEW IF EXISTS StudentsCredits;
CREATE VIEW StudentsCredits AS
2024-01-25 21:55:48 +01:00
SELECT Students.firstName, Students.lastName, sum(credits) as totalCredits
2024-01-25 21:17:11 +01:00
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;