0

This is my table: The table

Now I grouped classes and wanted to select the first_name from each group(class) with the highest marks.

But in class 7 group, I am getting 'edward' instead of 'tony' even though tony has higher marks. how should I order inside a group. I want to order by marks descending.

my output: MY output

1 Answers1

0

You can order by marks desc and use limit 1 only return the first line, which is the row with the highest mark.

Select firstname,marks
From student s
Order by marks desc
Limit 1