日期:2014-05-18 浏览次数:20527 次
select *,(select count(1) from t b where b.id<a.id) from t a -- order by a.id asc
------解决方案--------------------
--如果是分组排序: 首先给表加一个自动增长的排序列: alter table test add id int identity go --子查询实现 select px=(select count(1) from test b where a.col1=b.col1 and b.id<=a.id),* from test a
------解决方案--------------------
SQL2000要使用临时表 select identity(1,1) as id,* into #t1 from Infos