Skip to content

Instantly share code, notes, and snippets.

@ddikman
Created December 20, 2021 12:32
Show Gist options
  • Save ddikman/d05aeaea3b0eb8f7fb120c732724e307 to your computer and use it in GitHub Desktop.
Save ddikman/d05aeaea3b0eb8f7fb120c732724e307 to your computer and use it in GitHub Desktop.
Gets the app opens for the app over the past few weeks
SELECT
DATE(DATE_TRUNC(TIMESTAMP_MICROS(event_timestamp), WEEK)) as week,
COUNT(DISTINCT(user_pseudo_id)) as users
FROM `<project>.events_*`
WHERE event_name = 'app_open'
-- past six weeks
AND DATE(DATE_TRUNC(TIMESTAMP_MICROS(event_timestamp), WEEK)) > DATE_SUB(DATE_TRUNC(CURRENT_DATE(), WEEK), INTERVAL 6 WEEK)
GROUP BY week
ORDER BY week
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment