查询学生表中每个班级学生的最大年龄?

来源:百度知道 编辑:UC知道 时间:2024/06/25 08:47:48
select class_id,name,max(age)
from student
group by class_id
这样查询对吗?谢谢

先是group by用法错误
再一个,你这恐怕不止一个表吧?
得俩表关联吧?
一个学生表student(class_id,name,age)
一个班级表class(class_name,class_id)
select a.class_name,b.age from class a,
(select class_id,max(age) age from student group by class_id) b
where a.class_id=b.class_id