我面临以下困境。
我需要在Excel中rank
数据,就像在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 视频和如何在 Excel 中rank
的教程,但是我看不到{{1} } partition by
,如上面的代码所示。
请参见上面脚本的以下结果:
我可以在Excel中使用什么公式来获得相同的结果?
答案 0 :(得分:0)
答案 1 :(得分:0)
选中SUMPRODUCT。 here中的示例:
选择数据旁边的空白单元格(例如C2),键入 公式
=SUMPRODUCT(($A$2:$A$11=A2)*(B2<$B$2:$B$11))+1
然后向下拖动自动填充手柄,以将此公式应用于所需的单元格。
在公式中,A2:A11是包含组值的范围,A2是 组值列表中的第一个单元格,B2是中的第一个单元格 需要排名的列表,B2:B11是包含值的列表 需要排名。