我想对表中的行进行排名而不跳过排名中的数字。请看下面的例子。
CREATE TABLE #test(
apples int NOT NULL,
) ON [PRIMARY]
GO
insert into #test( apples ) values ( 10 )
insert into #test( apples ) values ( 10 )
insert into #test( apples ) values ( 20 )
insert into #test( apples ) values ( 30 )
select *, RANK() over (order by apples) as theRank from #test
drop table #test
go
结果是
apples theRank
10 1
10 1
20 3
30 4
我怎样才能让排名不跳过数字 2,这样结果看起来像
apples theRank
10 1
10 1
20 2<--
30 3<--
我不必使用 Rank 函数,只要我得到所需的排序即可。
谢谢!!