Select the course system, how many credits a student has selected, how to solve

Source: Internet
Author: User
Select the course system and count how many credits a student has selected
Selected Course Table info_selected
Field type
stu_id varchar (50)
Course_idint (11)

Student Table Info_student
Field type grooming property null default extra action
Idvarchar (GB2312_CHINESE_CI) No
Namevarchar (GB2312_CHINESE_CI) No
Deptvarchar (+) Gb2312_chinese_ci No
Majorvarchar (+) Gb2312_chinese_ci No
Sexchar (4) Gb2312_chinese_ci No
Classvarchar (GB2312_CHINESE_CI) No
Passwordvarchar (gb2312_chinese_ci) No e10adc3949ba59abbe56e057f20f883e

Timetable Info_course

Field type grooming property null default extra action
Idint (5) No auto_increment
Novarchar (GB2312_CHINESE_CI) No
Namevarchar (GB2312_CHINESE_CI) No
Teacher_idvarchar (GB2312_CHINESE_CI) No
Teacher_namevarchar (GB2312_CHINESE_CI) No
Selectedmanint (11) is 0
Capacityint (11) is null
Timevarchar (GB2312_CHINESE_CI) is null
Placevarchar (GB2312_CHINESE_CI) is null
Creditfloat is null

Count the total number of credits a student has chosen
How do you write this statement?

------Solution--------------------
SQL code
select y.stuid,sum (A.credit) from curriculum A, student table S, selected course y whe
   Re y.course_id=a.id GROUP by y.stu_id 
------Solution--------------------
2 Floor Less an association
SQL code
select a.name,sum (b.credit) from student table A, curriculum B, selection timetable cwhere a.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.