查找在蜂房以前的时间戳天的差异(Find the difference in days from p

2019-10-31 07:17发布

我想找到天差异,在我的目标表填充新列。 所不同的是通过从当前日期之前的创建日期。

请参考附件屏幕截图以供参考。

谢谢。

Answer 1:

使用LAG功能帮助您获得前一行和DATEDIFF得到的差异。

select
    id,
    function_id,
    key,
    pre_date,
    datediff(pre_date, lag(pre_date, 1) over(order by id)) as days_difference
from
    [Your_Table]


文章来源: Find the difference in days from previous timestamp in hive