Skip to content

Instantly share code, notes, and snippets.

@jaymay
Created July 14, 2015 22:54
Show Gist options
  • Save jaymay/ea1f40b417122223fc7f to your computer and use it in GitHub Desktop.
Save jaymay/ea1f40b417122223fc7f to your computer and use it in GitHub Desktop.
Mongo collections example
select case when u.roles in (2,3) then 'agent'
else 'user'
end role,
asr.target_audience,
count(*) num_views,
count(distinct unique_token) unique_tokens
from default.stats_hc_events hc
left outer join classic.users u on u.id = hc.user_id
inner join classic.account_survey_responses asr on asr.account_id = hc.account_id
where dt between 20150601 and 20150607 and hc.child_type = 'Article' and hc.type = 'child_view'
group by case when u.roles in (2,3) then 'agent'
else 'user'
end,
asr.target_audience
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment