todo:I grouped a set of data by c_id and took the data for the maximum value of the height of each group.
problem:The data that does not display the maximum value correctly like c_id=3 in picture no.2.
I want to ask how to fix it, thanks.
todo:I grouped a set of data by c_id and took the data for the maximum value of the height of each group.
problem:The data that does not display the maximum value correctly like c_id=3 in picture no.2.
I want to ask how to fix it, thanks.
You can check this query out:
SELECT `id`, `name`, `gender`, `age`, `c_id`, MAX(`height`) AS height
FROM `student`
GROUP BY `c_id`
ORDER BY `height` DESC;
Here is the Demo
select *
from student
where (c_id, age,height) in ( Select c_id
, max(age) age
, max(height) as height
from student
group
by c_id )
Try this
Select id, name, gender, age, c_id, height
From student
Where (c_id, age) in (Select c_id, max(age) from student group by c_id)
Order by height desc