求SQL语句

[img]http://dl.iteye.com/upload/picture/pic/128405/2af54070-97c9-3846-84ca-c2521ba3ab23.png[/img]

student表中数据如图:

求每个班级中年龄最小的学生的姓名

select 班级,姓名 from student where 生日 in(select max(s.生日) from student s group by s.班级 )

select 班级,max(生日) from tbl group by 班级

select '班级','姓名' from student t1 where not exists (select * from student t2 where t1.'生日'<t2.'生日' )

如果支持ROW_NUMBER() OVER的话我会用ROW_NUMBER() OVER,效率比较高

其具体用法参见http://www.cnblogs.com/fxgachiever/archive/2010/09/15/1826792.html

select 生日 from table group by 班级 order by 生日 asc

[size=medium]student(id ,name, birth,class)

select a.name from
stutdnet a, (select max(brith) birth , class from student group by class) b
where a.birth = b.birth and a.class = b.class[/size][size=medium][/size]

student(id ,name, birth,class)

select a.name from
stutdnet a, (select max(brith) birth , class from student group by class) b
where a.birth = b.birth and a.class = b.class