select * from (
select indexno=(select count(*) from tb where f1<=a.f1),a.f1,a.f2
from tb a ) aa order by indexno
select indexno=(select count(*) from tb where f1<=a.f1),a.f1,a.f2
from tb a ) aa order by indexno
,f1
,f2
from t1 t
order by f1
indexno = (selcet count(*) from t1 where f1<=a.t1),
a.f1,
a.f2
from
t1 a
order by
a.f1
应该是(select count(*) from t1 where f1<=a.f1)
select 序号=(select sum(1) from t1 where convert(varchar(10),f1)+convert(varchar(20),f2)<=
convert(varchar(10),a.f1)+convert(varchar(20),a.f2)),
f1,
f2
from t1 a
declare @t table (f1 int, f2 varchar(20))
insert into @t select 21,'A1'
union all select 19,'A6'
union all select 40,'A4'
union all select 20,'A6'--查询语句
select 序号=(select sum(1) from @t where convert(varchar(10),f1)+convert(varchar(10),f2)<=
convert(varchar(10),a.f1)+convert(varchar(10),a.f2)),
f1,f2
from @t a
order by 序号--结果
序号 f1 f2
----------- ----------- --------------------
1 19 A6
2 20 A6
3 21 A1
4 40 A4(所影响的行数为 4 行)