Skip to content

Instantly share code, notes, and snippets.

@Nxtra
Created July 22, 2020 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nxtra/313f9ff760968a2ee18a8454482a1f18 to your computer and use it in GitHub Desktop.
Save Nxtra/313f9ff760968a2ee18a8454482a1f18 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE PUMP "STREAM_PUMP_SPEED" AS
INSERT INTO "SPEED_SQL_STREAM"
SELECT STREAM
"uniqueId",
AVG("speed") over W0,
AVG("speed") over W2,
AVG("speed") over W10
FROM "INCOMING_STREAM"
WINDOW
W0 AS ( PARTITION BY "uniqueId"
RANGE INTERVAL '0' MINUTE PRECEDING),
W2 AS ( PARTITION BY "uniqueId"
RANGE INTERVAL '2' MINUTE PRECEDING),
W10 AS ( PARTITION BY "uniqueId"
RANGE INTERVAL '10' MINUTE PRECEDING);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment