sql sliding window - finding max value over interval

后端 未结 1 1106
一向
一向 2021-01-06 15:07

i have a sliding window problem. specifically, i do not know where my window should start and where it should end. i do know the size of my interval/window.

i need

相关标签:
1条回答
  • 2021-01-06 15:42
    SELECT  *,
            (
            SELECT  SUM(value)
            FROM    mytable mi
            WHERE   mi.tstamp BETWEEN m.tstamp - '2.5 minute'::INTERVAL AND m.tstamp + '2.5 minute'::INTERVAL
            ) AS maxvalue
    FROM    mytable m
    ORDER BY
            maxvalue DESC
    LIMIT   1
    
    0 讨论(0)
提交回复
热议问题