The course selection system calculates the total number of credits a student chooses. how can this problem be solved?

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.