Skip to content

Instantly share code, notes, and snippets.

@tjwaterman99
Created January 9, 2020 19:27
Show Gist options
  • Save tjwaterman99/6e8358abb7821cf854cc451f9aad59e6 to your computer and use it in GitHub Desktop.
Save tjwaterman99/6e8358abb7821cf854cc451f9aad59e6 to your computer and use it in GitHub Desktop.
# Flags users with a pageview during 2019. Faster than joining!
select
user.id,
exists(
select 1
from pageviews
where pageviews.user_id=users.id
and pageviews.created_at between '2019-01-01' and '2020-01-01'
limit 1
) as "active_2019"
from users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment