I have a few tables for a college.
Apply (sID int(3), cName varchar(20), major varchar(20), decision char(1))
College (cName char(20), state char(2), enrollment int(11))
Student (sid char(6), sName char(20), GPA decimal(3,2), sizeHS int(11))
I created this table:
CollegeStats (cName varchar(20), appCount int(11), minGPA decimal(3,2), maxGPA decimal(3,2))
I need to create a stored procedure that updates CollegeStats
, with no parameters based on Apply
, College
, and Student
table.
I've worked on several iterations of code to try to come to an answer, and this is my latest one. I'd really appreciates any and all help.
No parameter for this process.
ROUTINE NAME: updateCollegeStatsAll
BEGIN
UPDATE CollegeStats
SET appCount = (SELECT COUNT(*) FROM Apply),
minGPA = (SELECT MIN(GPA) FROM Student),
maxGPA = (SELECT MAX(GPA) FROM Student);
END
When I run this code it updates all the rows to be the same.
cName appCount minGPA maxGPA
-----------------------------------
Cornell 20 2.90 4.00
MIT 20 2.90 4.00
CALTEC 20 2.90 4.00
Davis 20 2.90 4.00