简体   繁体   English

用于为每个唯一 ID 选择最大日期和前 30 天之间的数据点的 Hive 查询

[英]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.

相关问题 每个组中最大日期之间的天数 - Days between max date in each group sql查询,用于选择具有时间间隔的30天数据 - sql query for selecting 30 days data with time interval 选择特定时期的前 5 个最大高点和 5 分钟低点,例如在同一查询中过去 180 天和 30 天 - selecting Top 5 max highs and 5 min Low for specific period say past 180 and 30 days in same query 为每行查询获取30天之前的数据 - Get 30 days prior data for each row of query 配置单元查询以按年份和ID获取日期列组的最小值和最大值 - Hive query to get min and max of date column group by year and id 我正在处理仪表板,我在其中询问前 30 天的日期和查询结果 - I am working on a dashboard where I ask for a date and query results for previous 30 days 想要从 DOB 计算出的从最大日期和年龄在 25 到 30 岁之间的客户过去 30 天的总收入 - want total revenue for last 30 days from max date and age of customers between 25 and 30 calculated from DOB 选择每个月的最大日期 - Selecting max date of each month JPA 标准查询以查找每个唯一名称的 MAX ID - JPA Criteria Query to find the MAX ID for each unique name Snowflake/SQL 计算每个日期过去 30 天内的不同用户 ID 计数 - Snowflake/SQL Calculate distinct user Id count in trailing last 30 days for each date
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM