Course selection system: calculates the total number of credits selected by a student in the course list info_selected & nbsp; field type & nbsp; stu_idvarchar (50) & nbsp; course_idint (11) student table info_student course selection system, count the total credits of a student
Selected course list info_selected
Field type
Stu_id varchar (50)
Course_idint (11)
Student table info_student
Field type sorting property Null default additional operations
Idvarchar (50) gb2312_chinese_ci no
Namevarchar (20) gb2312_chinese_ci no
Deptvarchar (40) gb2312_chinese_ci no
Majorvarchar (40) gb2312_chinese_ci no
Sexchar (4) gb2312_chinese_ci no
Classvarchar (20) gb2312_chinese_ci no
Passwordvarchar (50) gb2312_chinese_ci no e10adc3949ba59abbe56e057f20f883e
Curriculum info_course
Field type sorting property Null default additional operations
Idint (5) No auto_increment
Novarchar (50) gb2312_chinese_ci no
Namevarchar (50) gb2312_chinese_ci no
Teacher_idvarchar (50) gb2312_chinese_ci no
Teacher_namevarchar (50) gb2312_chinese_ci no
SelectedManint (11) is 0
Capacityint (11) is NULL
Timevarchar (50) gb2312_chinese_ci is NULL
Placevarchar (50) gb2312_chinese_ci is NULL
Creditfloat is NULL
Count the total credits of a student
How can I write this statement?
------ Solution --------------------
SQL code
Select y. stuid, sum (a. credit) from course List a, student table s, selected course y where y. course_id = a. id group by y. stu_id
------ Solution --------------------
One association is missing on the second floor.
SQL code
Select. name, sum (B. credit) from student Table a, course list B, course selection table cwhere. id = c. stu_id and B. id = c. course_id group by c. stu_id