mysql查询每个班上最小年龄的学员

sno    sname ssex  sbirthday                     class

101    李军    男     1976-02-20 00:00:00    95033
103    陆君    男     1974-06-03 00:00:00    95031
105    匡明    男     1977-10-02 00:00:00    95031
107    王丽    女     1976-01-23 00:00:00    95033
108    曾华    男     1977-09-01 00:00:00    95033
109    王芳    女     1975-02-10 00:00:00    95031
110    王芳    女     1978-02-10 00:00:00    95031
111    王五    男     1974-06-01 00:00:00    95033

 

查询每个班上年纪最小的学员。

不要limit做,会导致班级定死,如果有很多个班级就不方便使用limit了

错误代码:

select * from students where year(sbirthday) in(select max(year(sbirthday)) from students group by class) ;

 

select * from students where year(sbirthday) in(select max(year(sbirthday)) from students group by class) group by class;

select * from students  where (year(sbirthday),class)in(select max(year(sbirthday)),class from students group by class)

select max(sbirthday) from students  group by class

group by 只取一条

 

select sno, sname, ssex, min(sbirthday), class from student group by class;

望采纳

select s.* 
from students s 
join (select class,max(year(sbirthday)) m from students group by class) t 
on s.class = t.class 
where year(sbirthday)=t.m;

查询年龄最小的学生的所有信息怎么写,谢谢,最简便的

select * from students where year(sbirthday) in(select max(year(sbirthday)) from students group by class) ;

这种好像是对的啊。有啥问题