Skip to content

Instantly share code, notes, and snippets.

@kgorman
Last active October 25, 2019 16:26
Show Gist options
  • Save kgorman/a33342607ae152c6a04c9d97b124aa4a to your computer and use it in GitHub Desktop.
Save kgorman/a33342607ae152c6a04c9d97b124aa4a to your computer and use it in GitHub Desktop.
sample4.sql
-- return aggregation of total payments
-- over a 1 hour tumbling window
SELECT SUM(CAST(amount AS numeric)) AS payment_volume,
CAST(TUMBLE_END(eventTimestamp, interval '1' hour) AS varchar) AS ts
FROM payments
GROUP BY TUMBLE(eventTimestamp, interval '1' hour);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment