Last active
December 19, 2015 02:59
-
-
Save jgonera/5886955 to your computer and use it in GitHub Desktop.
SQL for fetching stats about uploaders
This file contains hidden or 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
| -- show users that uploaded at least twice | |
| select | |
| event_userName, | |
| count(*) as count | |
| from MobileWebUploads_5383883 | |
| where | |
| event_action = 'success' | |
| and wiki != 'testwiki' | |
| group by event_userName | |
| having | |
| count >= 2; | |
| -- show users who uploaded both in April and May | |
| select | |
| event_userName, | |
| count(*) as count, | |
| period_diff(extract(year_month from max(timestamp)), extract(year_month from min(timestamp))) as month_diff | |
| from MobileWebUploads_5383883 | |
| where | |
| event_action = 'success' | |
| and wiki != 'testwiki' | |
| and timestamp >= '20130401' -- be sure to include day, else will give false results | |
| and timestamp < '20130601' -- be sure to include _next_ day, else will give false results | |
| group by event_userName | |
| having | |
| count >= 2 | |
| and month_diff >= 1; | |
| -- show users who uploaded at least twice, at least 30 days apart | |
| select | |
| event_userName, | |
| count(*) as count, | |
| datediff(max(timestamp), min(timestamp)) as day_diff | |
| from MobileWebUploads_5383883 | |
| where | |
| event_action = 'success' | |
| and wiki != 'testwiki' | |
| -- and timestamp >= '20130401' -- optional, be sure to include day, else will give false results | |
| -- and timestamp < '20130601' -- optional, be sure to include _next_ day, else will give false results | |
| group by event_userName | |
| having | |
| count >= 2 | |
| and day_diff >= 30; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment