Skip to content
Advertisement

sum of consecutive values

I have following data in a Teradata table. My requirement is a consecutive sum between OFFLOAD_SECONDS <5 MInutes(300seconds) and ignore the OFFLOAD_SECONDS value where OFFLOAD_SECONDS >=5Minutes and do the rolling sum until we get offload_seconds >=5 minutes.

My Current Data.

Output

Advertisement

Answer

This query should give you expected output. Let me know.

http://sqlfiddle.com/#!17/4a4fb/3

Alternatively, this longer version with extra select wrapping the above SQL, also works:

http://sqlfiddle.com/#!17/4a4fb/13

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement