MYSQL数据库中有一张学生成绩表
表名:table
字段: student(学生), class(班级), total(总分)
字段说明: 班级取值范围 1-10,一共10个班。
请用SQL查出每个班级的前三名
select *
from tb t
where (select count(1)+1 from tb where class=t.class and marks>t.marks)<=3;
select *
from tb t;
MYSQL数据库中有一张学生成绩表
表名:table
字段: student(学生), class(班级), total(总分)
字段说明: 班级取值范围 1-10,一共10个班。
请用SQL查出每个班级的前三名
select *
from tb t
where (select count(1)+1 from tb where class=t.class and marks>t.marks)<=3;
select *
from tb t;