Hi,
If I want to find out highest score student from each class, how can I
do that in MySQL? Assume the table looks like:
classId INT,
studentId INT,
score INT
In the case of multiple students from the same class has the same
highest score, I would like to get the first one whose studentId is
You are looking for a minimum value _within_ a maximum set. In this case,
that will take two processing steps:
DECLARE TEMPORARY TABLE tmpScores
SELECT classid, Max(score) as topscore
FROM tablename_goes_here
GROUP BY classid;
SELECT t.classid, t.Min(studentid), ts.topscore
FROM