hi~ 我想问个sql问题,
班级代码(classno),学生编号(stuno),数学分数(sxscore)
我想求出每个班分数最高的`人` 怎么求?
classno,stuno, A 001 100
A 002 95
B 001 89
B 002 96
C 001 89
C 002 96
就是类似这样。
班级代码(classno),学生编号(stuno),数学分数(sxscore)
我想求出每个班分数最高的`人` 怎么求?
classno,stuno, A 001 100
A 002 95
B 001 89
B 002 96
C 001 89
C 002 96
就是类似这样。
from test a
where sxscore=(select max(sxscore) from test where classno=a.classno)
order by classno
select * from table a
where a.stuno=(select top 1 stuno from table where a.classno=classno order by sxcore desc)
如果要取并列的话
select * from table a
where a.sxcore=(select top 1 sxcore from table where a.classno=classno order by sxcore desc)