Created
January 29, 2015 14:43
-
-
Save rpavlovic/d7699dd92daa424ddcce to your computer and use it in GitHub Desktop.
Wordpress SQL: average comments per day over time
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
SELECT | |
'2010-11-24' AS date_begin, | |
'2015-01-26' AS date_end, | |
day_of_week, | |
AVG(comment_count) AS average_comments | |
FROM ( | |
SELECT | |
comment_date, | |
DAYNAME(comment_date) day_of_week, | |
DAYOFWEEK(comment_date) day_num, | |
TO_DAYS(comment_date) date, | |
COUNT(*) AS comment_count | |
FROM | |
wp_comments | |
GROUP BY | |
comment_date | |
) temp_table | |
WHERE | |
comment_date >= '2010-11-24' | |
AND | |
comment_date < '2015-01-27' | |
GROUP | |
BY day_of_week | |
ORDER | |
BY day_num; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment