如何使用排名功能获取Hive中的最新记录 [英] How to get the latest records in hive using rank function
本文介绍了如何使用排名功能获取Hive中的最新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在蜂巢中有下表,其中包含列ID,名称和时间戳记:
I have below table in hive with column id, name and time stamp:
根据以下时间戳记,应将输出作为最新记录:
On the basis of time stamp below should be the output as latest record:
推荐答案
您不需要为此排名.您的输出描述如下:
You don't need rank for this. Your output is described by:
select t.*
from t
order by t.transaction_time desc
limit 3;
哦,您要rank()
或dense_rank()
:
select t.*
from (select t.*,
dense_rank() over (order by t.transaction_time desc) as seqnum
from t
) t
where seqnum = 1;
这篇关于如何使用排名功能获取Hive中的最新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文