我应该使用哪个 Oracle 分析函数来获得此结果?
可能是个愚蠢的问题,但今天是周日,我的思维无法正常运转。我正在尝试使用分析函数来获取以下结果
我有这个查询(这只是一个记录的一个小例子,但足以解释我想要解释的内容)
select h.party_number,organization_name,address_line1,address_type
,row_number() over(partition by party_number,organization_name,address_line1 order by address_line1,address_type ) as newrn
from h
where party_number = 'FI-110584'
order by address_type,party_number;
这给了我这个结果
什么我真正想要的是party_number、organization_name 和 adress_line1 的组合具有相同的排名(因此具有相同的数字)
因此,最后一列应类似于
1
1
2
因为相同的 party_number、organization_name 和 address_line 应具有相同的排名值。
我应该在这里使用什么分析函数?我尝试了 dense_rank
和 rank
但没有成功。
谢谢大家
Probably a dummy question, but it is Sunday and my mind does not work as it should be. I am trying to use an analytic function to get the following
I have this query ( it is just a small example of one record but enough for what I am trying to explain )
select h.party_number,organization_name,address_line1,address_type
,row_number() over(partition by party_number,organization_name,address_line1 order by address_line1,address_type ) as newrn
from h
where party_number = 'FI-110584'
order by address_type,party_number;
Which gives me this result
What I really want is to have the same ranking ( so the same number ) for the combination of party_number, organization_name and adress_line1
So, the last column should look like
1
1
2
Because the same party_number, organization_name and address_line should be given the same ranking value.
What analytic function should I use here ? I tried dense_rank
and rank
with no success.
Thank you all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对我来说,它看起来像是您正在寻找的
DENSE_RANK
withoutADDR
列:To me, it looks like it is
DENSE_RANK
withoutADDR
column you're looking for:您的分区和排序有点不对:
db>>fiddle
Your partitioning and ordering is a little off:
db<>fiddle
您需要的是 DENSE_RANK,而不是 ROW_NUMBER -
You need a DENSE_RANK not ROW_NUMBER -