select min(id), max(id), min(datetime), max(datetime),
avg(engine_load)
from (select t.*,
sum(case when prev_datetime > datetime - interval 3 minute then 0 else 1 end) over (order by datetime) as grp
from (select t.*,
lag(datetime) over (order by datetime) as prev_datetime
from t
) t
) t
group by grp;
1条答案
按热度按时间j2cgzkjk1#
如果您将休息时间定义为三分钟,那么您可以使用
lag()
然后是定义组的累积和: