Excel排名与SQL排名

比雷尔

我有以下困境。

我需要rank在Excel中进行数据处理,就像在SQL中数据进行排名一样,如下所示:

declare @table table
(id int identity primary key , batchid int)

insert into @table (batchid) select 10
insert into @table (batchid) select 35
insert into @table (batchid) select 35
insert into @table (batchid) select 35
insert into @table (batchid) select 8
insert into @table (batchid) select 21
insert into @table (batchid) select 10
insert into @table (batchid) select 11
insert into @table (batchid) select 4
insert into @table (batchid) select 10
insert into @table (batchid) select 11
insert into @table (batchid) select 4
insert into @table (batchid) select 21
insert into @table (batchid) select 8
insert into @table (batchid) select 21
insert into @table (batchid) select 8
insert into @table (batchid) select 21
insert into @table (batchid) select 4
insert into @table (batchid) select 21
insert into @table (batchid) select 10
insert into @table (batchid) select 21
insert into @table (batchid) select 11
insert into @table (batchid) select 21
insert into @table (batchid) select 8
insert into @table (batchid) select 21
insert into @table (batchid) select 10
insert into @table (batchid) select 21
insert into @table (batchid) select 10
insert into @table (batchid) select 21

select
batchid
,   rank() over (partition by batchid order by id)  [RANK]
from    @table

我看了很多的YouTube视频,以及如何的教程rankExcel中,但我没有看到选项,partition byrank如在上面的代码中可以看出。

请参阅上述脚本的以下结果:

在此处输入图片说明

我可以在Excel中使用什么公式来获得相同的结果?

米恰尔·图尔钦(MichałTurczyn)

使用简单的公式非常容易:

在此处输入图片说明

在单元格中B1输入初始值1然后,在B2您输入公式:

=IF(A1=A2,B1+1,1)

然后将其一直向下拖动。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章