select 姓名,数学成绩, (identity(int,1,1)) as 数学成绩排名 into #Tm from tablename order by 数学成绩 descselect 姓名,英语成绩, (identity(int,1,1)) as 英语成绩排名 into #Tm from tablename order by 英语成绩 descselect 姓名,总成绩, (identity(int,1,1)) as 总排名 into #Te from tablename order by 总成绩 descselect a.姓名,a.数学成绩,a.数学成绩排名,b.英语成绩, b.英语成绩排名,c.总成绩, c.总排名 from #Tm a,#Te b,#Ts c where a.姓名=b.姓名 and a.姓名=c.姓名 order by 总排名
godrop table #Tm
drop table #Te
drop table #Ts
godrop table #Tm
drop table #Te
drop table #Ts
,英语成绩,英语成绩排名=(select sum(1) from 表 where 英语成绩>=a.英语成绩)
,总成绩 ,总成绩排名=(select sum(1) from 表 where 总成绩>=a.总成绩)
from 表 a