sql - From a certain number of rows with the same primary key, how do I select the ones with the highest value in a certain column? -
i have students table , grades table.
- students has columns student_id(primary key), name, date_of_birth, address, email, , level.
- grades has columns student_id(primary/foreign key), course_id(primary/foreign key), , grade.
"grades" looks this:
student_id|course_id|grade =========================== 1 | 1 | 1 | 2 | b 1 | 3 | 3 | 1 | f 3 | 3 | c . . . .
this isn't whole table, gist. i'm trying write query selects name of student , student's highest grade. i'm new sql 1 little confusing me. attempt far this:
select "students".name, "grades".grade "students" inner join "grades" on "students".student_id = "grades".student_id group name, grade having min(grade) <= 'f';
it's wrong, , know why, i'm not sure go here.
select students.name, min(enroll.grade) students inner join enroll on students.student_id = enroll.student_id group name,
Comments
Post a Comment