Student表:
方法一:嵌套查询
select s2.* from
(
select class,max(age) Age from
Student
group by
class
) s1
left join
Student s2
on s1.class=s2.class
and s1.age=s2.age;
结果集:
方法二:with as
with max_age as(
select class,max(age) Age from
Student
group by
class
)
select stu.*
from
max_age ma
join
Student stu
on
ma.class=stu.class
and ma.age=stu.age
结果集: