I have a Students table and a Grades table.
- Students has columns student_id(primary key), name, date_of_birth, address, email, and level.
- Grades has columns student_id(primary/foreign key), course_id(primary/foreign key), and grade.
"Grades" looks like this:
student_id|course_id|grade
===========================
1 | 1 | A
1 | 2 | B
1 | 3 | A
3 | 1 | F
3 | 3 | C
.
.
.
.
This isn't the whole table, but you get the gist. I'm trying to write a query which SELECTS the name of a student and that student's highest grade. As I'm new to SQL this one is a little confusing for me. My attempt so far is this:
SELECT "Students".name, "Grades".grade FROM "Students" INNER JOIN
"Grades" ON "Students".student_id = "Grades".student_id GROUP BY name,
grade HAVING MIN(grade) <= 'F';
It's wrong, and I know why, but I'm not sure where to go from here.