34,873
社区成员
发帖
与我相关
我的任务
分享
select *,个数= (select count(*) from 表 where a.字段<b.字段 and a.字段=字段) from 表 a
--1,sql2000
select *,id=identity(int,1,1) into # from tb
select * from #
drop tabel #
---2,sql2005
select*,id=row_number() over (order by getdate()) from tb
/*****
1,sql2000
select *,id=identity(int,1,1) into # from tb
select * from #
drop tabel #
2,sql2005
select*,id=row_number() over (order by getdate()) from tb
***/
--SQL 2005
select *,id=row_number() over (order by getdate())
from tbselect *,NO=(select count(*) from tb where tel<=t.tel)from tb tselect * from #select *,id=identity(int,1,1) into # from tb