hi, i have a table in which I need to calculate the max among the previous 30 days for every record , is there a way in hive with sub queries?, see below for sample data
You can try hive windowing function. Something like below.
select tdate,var, max(var) over (order by tdate ROWS between CURRENT ROW AND 30 FOLLOWING ) maxvar from testwindow;
You can also include "PARTITION BY" clause if you need to group it by some other column/s.