Hive 选择配置单元中的最大时间戳
我有一个表customer,在不同的时间戳中有两条记录。我想选择最大时间戳记录:2014-08-15 15:54:07.379Hive 选择配置单元中的最大时间戳,hive,conditional,max,datetime-format,Hive,Conditional,Max,Datetime Format,我有一个表customer,在不同的时间戳中有两条记录。我想选择最大时间戳记录:2014-08-15 15:54:07.379 Select Customer_ID, Account_ID, max(ProcessTimeStamp) from Customer group by Customer_ID, Account_ID 我应该得到一个记录,但实际结果是两个记录 如何获取最大进程时间戳记录?您可以在此处使用windows函数。 您可以使用densite_rank()或row_num(
Select Customer_ID, Account_ID, max(ProcessTimeStamp)
from Customer
group by Customer_ID, Account_ID
我应该得到一个记录,但实际结果是两个记录
如何获取最大进程时间戳记录?您可以在此处使用windows函数。 您可以使用densite_rank()或row_num() 1.使用稠密_秩() 2.使用行号
select customer_id,account_id,processTimeStamp
from (select *
,row_number() over(partition by customer_id order by processTimeStamp desc) as rank
from "your table"
) temp
where rank=1
但是使用row_number()时,每一行将获得一个唯一的编号,如果有重复的记录,则row_number将只给出row number=1的行(在上述情况下)。您按具有不同值的帐户ID进行分组,因此结果是正确的。您好,Vishal,我将验证您的解决方案,并在完成后返回给您。谢谢
select customer_id,account_id,processTimeStamp
from (select *
,row_number() over(partition by customer_id order by processTimeStamp desc) as rank
from "your table"
) temp
where rank=1