Skip to content

Instantly share code, notes, and snippets.

@ivanpk

ivanpk/article3.sql Secret

Last active Feb 5, 2020
Embed
What would you like to do?
WITH daily AS (
SELECT
DATE(created_at) day,
user_id
FROM
`example-project.ivan.article_example_dataset`
)
SELECT
day,
SUM(APPROX_COUNT_DISTINCT(user_id)) OVER (ORDER BY day ROWS BETWEEN 89 PRECEDING AND CURRENT ROW) ninty_day_window_approx
FROM
daily
GROUP BY
1
ORDER BY
1 DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment