Skip to content

Instantly share code, notes, and snippets.

@benmay
Created February 21, 2013 06:36
Show Gist options
  • Save benmay/5002723 to your computer and use it in GitHub Desktop.
Save benmay/5002723 to your computer and use it in GitHub Desktop.
Grab number of comments on posts during 2012, in category cricket.
SELECT SUM(p.comment_count) FROM wp_posts p
JOIN wp_term_relationships tr ON tr.object_id = p.ID
JOIN wp_term_taxonomy tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
JOIN wp_terms t ON t.term_id = tt.term_id
WHERE t.name = 'Cricket'
AND `post_date` >= '2012-01-01 00:00:00'
AND `post_date` <= '2013-01-01 00:00:00'
AND p.post_status = 'publish'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment