I have a table of grades/courses. I am trying to see how many times a person has taken a course, and also return the highest grade they have achieved.
So far I have:
SELECT tnumber, courseid, grade FROM grades
For example (table alias G not necessary as only 1 table is involved using for example only)
SELECT g.tnumber, g.courseid, min(g.grade), count(*) FROM grades g GROUP BY g.tNumber, g.CourseID
This returns the tnumber and courseID for each record with the highest (alphabetic grade) and a count of how many records exist for that same tnumber and courseID. You could use count(*) or count(1).
Based on a prior posts I'm assuming grade is alphabetic.