select identity(int,1,1) as id,* into # from tbl order by totol
select
(select count(1)+1 from # where totol<=T.totol and id<t.id) as no,
(select count(1)+1 from # where class=T.class and totol<=T.totol and id<t.id) as 序号,
T.name,T.class,T.totol
from # T
order by totol
select
(select count(1) from tbl where totol<=T.totol) as no,
(select count(1) from tbl where class=T.class and totol<=T.totol) as 序号,
T.name,T.class,T.totol
from tbl T
order by totol