因帕拉:1小时的运行总和

问题描述 投票:0回答:1

我想在1小时计算每个ID记录用。我尝试了一些IMPALA查询,但没有任何的运气。

我有输入数据如下:

enter image description here

和预期产出将是:

enter image description here

我试过了 :

select
      concat(month,'/',day,'/',year,' ',hour,':',minute) time, id,
     count(1) over(partition by id order by concat(month,'/',day,'/',year,' ',hour,':',minute) range between '1 hour' PRECEDING AND CURRENT ROW) request
       from rt_request
       where
    concat(year,month,day,hour) >= '2019020318' 
group by id, concat(month,'/',day,'/',year,' ',hour,':',minute)

但我得到了异常。

RANGE仅与下限和上限无界或一个无界和其他CURRENT ROW双方都支持。

任何建议/帮助将不胜感激。先感谢您!

hadoop hive hql impala
1个回答
1
投票

我认为你是在这几天找计数同一时刻对于给定的ID。你可以简单地使用row_number做到这一点。

select time,id,row_number() over(partition by id,hour order by concat(month,'/',day,'/',year,' ',hour,':',minute)) as total
from tbl
© www.soinside.com 2019 - 2024. All rights reserved.