[英]Hive query for selecting data points in between max date and previous 30 days for each unique id
Data Contains unique IDs with different latitudes and longitudes on multiple timestamps.I would like to select the rows of latest 30 days of coordinates for each unique ID.Please help me on how to run the query .数据包含在多个时间戳上具有不同纬度和经度的唯一 ID。我想为每个唯一 ID 选择最近 30 天坐标的行。请帮助我如何运行查询。 This date is in Hive table.unable write the sub query此日期在 Hive 表中。无法编写子查询
You can use window functions:您可以使用窗口函数:
select t.*
from (select t.*,
max(date) over (partition by id) as max_date
from t
) t
where date > date_add(max_date, -30);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.