select 序号,row_number() over (partition by 班级 order by 成绩) as 班名次,row_number() over (order by 成绩) as 级名次 from T1
晕,我忘了你的是Access,Access没有row_number()函数
access比较难写,也比较难看懂,认真看,这句应该可行的:
select 序号,(select count(*) from T1 as a where a.成绩>=c.成绩 and a.班级=c.班级) as 班名次,(select count(*) from T1 as b where b.成绩>=c.成绩) as 级名次 from T1 as c
再次晕倒,还有并列名次的问题,不过这难不倒我,以上查询改成:
select 序号,(select count(*)+1 from T1 as a where a.成绩>c.成绩 and a.班级=c.班级) as 班名次,(select count(*)+1 from T1 as b where b.成绩>c.成绩) as 级名次 from T1 as c
花了点时间测试:通过