蜂巢中的分区排名
Rank Over Partition in hive
我在 table A 中有数据,如下所示,有 3 列 属性 id、结束日期和键,键字段必须为每个唯一组合填充一个唯一值属性 id和结束日期如下所示
key property id end date
1 7050 12/31/9999
2 7530 12/31/9999
2 7530 12/31/9999
2 7530 12/31/9999
2 7530 12/31/9999
3 7541 12/31/9999
3 7541 12/31/9999
3 7541 12/31/9999
4 7567 12/31/9999
4 7567 12/31/9999
我试过
select rank() over (partition by property_id,effective_end_date) as key,
property_id,
end_date
from table A
但它指定 1 作为所有记录的键。请帮助
使用下面的命令,使用命令:
select rank() over (ORDER by property_id,effective_end_date) as key,
property_id,
effective_end_date from table A
只需添加 Order by 即可,如下所示:
select rank() over (partition by property_id order by effective_end_date) as key,
property_id,
end_date
from table A
我在 table A 中有数据,如下所示,有 3 列 属性 id、结束日期和键,键字段必须为每个唯一组合填充一个唯一值属性 id和结束日期如下所示
key property id end date
1 7050 12/31/9999
2 7530 12/31/9999
2 7530 12/31/9999
2 7530 12/31/9999
2 7530 12/31/9999
3 7541 12/31/9999
3 7541 12/31/9999
3 7541 12/31/9999
4 7567 12/31/9999
4 7567 12/31/9999
我试过
select rank() over (partition by property_id,effective_end_date) as key,
property_id,
end_date
from table A
但它指定 1 作为所有记录的键。请帮助
使用下面的命令,使用命令:
select rank() over (ORDER by property_id,effective_end_date) as key,
property_id,
effective_end_date from table A
只需添加 Order by 即可,如下所示:
select rank() over (partition by property_id order by effective_end_date) as key,
property_id,
end_date
from table A