如果studentid连续的话 select (select count(*) from score where studentid<a.studentid) as xh,studentid,score from score a
select (select count(*) from score where studentid<=a.studentid) as xh,studentid,score from score a oder by xh
我也来一个: select xh=identity(int,1,1),* into #a from TB select * from #a drop table #a
select identity(int,1,1) as xh,* into #a from TB ORDER BY studentid select * from #a该方法只能适用于无IDENTITY关键字表 select (select count(*) from score where studentid<=a.studentid) as xh,studentid,score from score a oder by xh序号从0开始排
select (select count(*) from score where studentid<a.studentid) as xh,studentid,score from score a
select xh=identity(int,1,1),* into #a from TB
select * from #a
drop table #a
ORDER BY studentid
select * from #a该方法只能适用于无IDENTITY关键字表
select (select count(*) from score where studentid<=a.studentid) as xh,studentid,score from score a oder by xh序号从0开始排