I have this schema:
Students
(sid: int, firstName: str, lastName: str, yearStarted: int)Majors
(sid: int, major: str)
Note: a student may have more than one major.Grades
(sid: int, cid: int, credits: int, grade: int)
Note: sid, cid=foreign keys, grades: A=4, B=3, C=2, D=1, F=0.Courses
(cid: int, number: int, professor: str, major: str, year: int, semester: str) Note: cid is unique across semesters. Semester is either Summer, Fall, or Spring. Two course offerings are the same if they have same number + major
And with this schema I need to "Provide the SQL query that will generate the first name, last name, yearStarted, and the total number of credits for every student. You should not consider courses with a 0 grade, since these correspond to failed courses"
So far I have this:
def q4(self):
query = '''
select s.firstName, s.lastName, s.yearStarted,count(*)
from students s, grades g
where s.sid = g.sid
and g.grade >0
group by s.firstName, s.lastName, s.yearStarted
'''
self.cur.execute(query)
all_rows = self.cur.fetchall()
return all_rows
and returns these values:
[('Anne', 'Brown', 2020, 1), ('Jack', 'Thomson', 2018, 3), ('Jacob', 'McKarthy', 2020, 2), ('Jamal', 'Jones', 2019, 3), ('Jane', 'Doe', 2017, 2), ('John', 'Doe', 2017, 3), ('Tim', 'Burton', 2018, 3), ('Tina', 'Gilligan', 2019, 3)]
But apparently these are wrong, and when I upload to gradescope it gives me these errors located in the attached image
Any ideas what I am doing wrong?