There is a student(id_student, stname, averagemark, id_group)
table student(id_student, stname, averagemark, id_group)
. The task is to get one student from the group with the highest grade. Here is my option:
SELECT s1.stname, (SELECT max(averagemark) FROM student AS s2 WHERE s2.id_group = s1.id_group) AS averagemark, s1.id_group FROM student AS s1 ORDER BY id_group;
But he displays all the students with the highest mark (that is, if the table in the group 101 has five students the highest mark, the result will show all five. But one is needed)
Thank you in advance!
select top 1
? - andreychaTOP 1
- MANKK