Hello Everyone,
I have been struggling for hours with trying to figure out how I can return the average GPA across all sections that a professor teaches. Here is the code that I have so far. I know would only need Section and Registration tables in order to output this type of procedure that I want, but it is not producing the right results. Can someone please help me? Here is my ERD model attached below in case you need to know the relationships of each table.
I have been struggling for hours with trying to figure out how I can return the average GPA across all sections that a professor teaches. Here is the code that I have so far. I know would only need Section and Registration tables in order to output this type of procedure that I want, but it is not producing the right results. Can someone please help me? Here is my ERD model attached below in case you need to know the relationships of each table.
Code:
USE COLLEGE; DROP PROCEDURE IF EXISTS Faculty_GPA ; DELIMITER $$ CREATE PROCEDURE Faculty_GPA(IN FacultyID INT, OUT outavgGPA decimal(4, 2)) BEGIN DECLARE theGPAInfo DECIMAL(4,2); SET theGPAInfo= (SELECT AVG(registration.Grade) FROM Registration INNER JOIN Student ON registration.ID= Student.ID INNER JOIN Section ON Student.ID= Section.ID WHERE section.ID= 2 AND section.ID= 3); SET outavgGPA= theGPAInfo; END $$ DELIMITER ; CALL Faculty_GPA(2, @averageGPA); SELECT @averageGPA as GPA;