Skip to content

Instantly share code, notes, and snippets.

@saptarshiguha
Created November 1, 2017 22:59
Show Gist options
  • Save saptarshiguha/6ecb03e9c20ba93452246622afe7a637 to your computer and use it in GitHub Desktop.
Save saptarshiguha/6ecb03e9c20ba93452246622afe7a637 to your computer and use it in GitHub Desktop.
## For Session Hours Per Day Per Profile
### For profiles on 56
with a as (
select client_id, submission_date_s3, sum(subsession_length)/3600 as hours
from main_summary
where app_name='Firefox'
and substring(app_version,1,2)='56'
and submission_date_s3 >= '2017-09-25'
and subsession_length<=86400 and subsession_length>=0
group by 1,2
)
select submission_date_s3, avg(hours),geometric_mean(hours) from a group by submission_date_s3 order by 1
### For ALL profiles, but similar time periods
with a as (
select client_id, submission_date_s3, sum(subsession_length)/3600 as hours
from main_summary
where app_name='Firefox'
and submission_date_s3 >= '2017-09-25'
and subsession_length<=86400 and subsession_length>=0
group by 1,2
)
select submission_date_s3, avg(hours),geometric_mean(hours) from a group by submission_date_s3 order by 1
## Pages Visited
### For profiles on 56
with a as (
select client_id, submission_date_s3, sum(scalar_parent_browser_engagement_total_uri_count ) as turi
from main_summary
where app_name='Firefox'
and substring(app_version,1,2)='56'
and submission_date_s3 >= '2017-09-25'
and subsession_length<=86400 and subsession_length>=0
group by 1,2
)
select submission_date_s3, avg(turi ),geometric_mean(turi) from a group by submission_date_s3 order by 1
### For ALL profiles, but similar time periods
with a as (
select client_id, submission_date_s3, sum(scalar_parent_browser_engagement_total_uri_count ) as turi
from main_summary
where app_name='Firefox'
and submission_date_s3 >= '2017-09-25'
and subsession_length<=86400 and subsession_length>=0
group by 1,2
)
select submission_date_s3, avg(turi ),geometric_mean(turi) from a group by submission_date_s3 order by 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment