Created
July 6, 2012 16:30
-
-
Save mikebuchanon/3061191 to your computer and use it in GitHub Desktop.
Average logins per hour by day of week
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with user_stats as ( | |
select extract(dow from to_timestamp(time)) as day_of_week, | |
extract(hour from to_timestamp(time)) as hour_of_day, | |
count(1) as logins | |
from mdl_log | |
where action='login' | |
and to_timestamp(time) > '6/30/2012' | |
group by extract(dow from to_timestamp(time)), extract(hour from to_timestamp(time)) | |
) | |
select day_of_week, hour_of_day, avg(logins) as avg_logins | |
from user_stats | |
group by day_of_week, hour_of_day | |
order by day_of_week, hour_of_day; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment