Disclaimer . I am SQL newb and this is for the class, but I can really use the notch in the right direction.
I have three tables:
student(_sid_, sname, sex, age, year, gpa)
section(_dname_, _cno_, _sectno_, pname)
enroll(_sid_, grade, _dname_, _cno_, _sectno_)
(primary keys indicated by underscores)
I am trying to write an Oracle compatible SQL query that returns a table with student name ( student.sname) with the highest gpa value in each section (including section.cnoand section.sectno), as well as all other attributes from section.
I managed to use the aggregated query and GROUP BYto get the maximum GPA for each section:
SELECT MAX(s.gpa), e.cno, e.sectno
FROM enroll e,
student s
WHERE s.sid = e.sid
GROUP BY e.cno, e.sectno
section, , (student.sname). SELECT, GROUP BY, . WHERE FROM , , .
, , !