join - MySQL Query Database -


I have two tables student and takes

Student: ID, name, dept_name

takes: ID, course_ID, grade

I need to find the ID and name of each student, and the total number of their credit has been taken but it does not count where the student Got F grade.

This is where I am yet, but it is wrong that it will take the name of a single student, and will complete all credits as students.

  Select the student. ID, student. Name, Count (Course_ID) Student receives credit from WHERE student. Id = le. Id and moves. Grid! = 'F'; Results ID Name Credit 001 stud1 20  

To get the count of each student, > Group BY student ( s.ID, s.name ):

  SELECT s.ID, s.name, COUNT (*) AS INNER As student of JOIN SID takes the form of credit as T.ID = T. Grad! = 'F' Group SID, S. Name  

I guess some curriculum estimates for more credit than others, so if you have an area that shows how much credit for each course , You might want to link that table and use COUNT (*) instead of SUM (CreditVal) . Something like this:

  SELECT s.ID, s.name, SUM (c.credits) AS, AS INER JOIN as Total Students, SID = TID AS C CID = T CCARS_ID WHERE t.grade! = 'F' Group s.ID, s.name  

In the above question just change the c ID = t.course_id field to which two tables are Let's link together.


Comments