简体   繁体   中英

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 . This date is in Hive table.unable write the sub query

你好

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM