Skip to content

Instantly share code, notes, and snippets.

@atopal
Created September 18, 2013 10:48
Show Gist options
  • Select an option

  • Save atopal/6607477 to your computer and use it in GitHub Desktop.

Select an option

Save atopal/6607477 to your computer and use it in GitHub Desktop.
Helpfulness by source
SELECT all_votes.created_date , positive_votes.votes as positive_votes, all_votes.votes as all_votes, (positive_votes.votes / all_votes.votes*100) as helpfulness
FROM
(
SELECT DATE(`wiki_helpfulvote`.`created`) as created_date, count(*) as votes
FROM `wiki_helpfulvote`
JOIN `wiki_helpfulvotemetadata` ON `wiki_helpfulvotemetadata`.`vote_id`=`wiki_helpfulvote`.`id`
WHERE `wiki_helpfulvote`.`created` BETWEEN "2012-09-10 0" AND "2012-09-11 0"
AND `wiki_helpfulvotemetadata`.`key` = "referrer"
AND `wiki_helpfulvotemetadata`.`value` LIKE "%.mozilla.org%"
AND `wiki_helpfulvotemetadata`.`value` NOT LIKE "%://support.mozilla.org%"
GROUP BY DATE(`wiki_helpfulvote`.`created`)
) as all_votes
JOIN
(
SELECT DATE(`wiki_helpfulvote`.`created`) as created_date, count(*) as votes
FROM `wiki_helpfulvote`
JOIN `wiki_helpfulvotemetadata` ON `wiki_helpfulvotemetadata`.`vote_id`=`wiki_helpfulvote`.`id`
WHERE `wiki_helpfulvote`.`created` BETWEEN "2012-09-10 0" AND "2012-09-11 0"
AND `wiki_helpfulvote`.`helpful` = "1"
AND `wiki_helpfulvotemetadata`.`key` = "referrer"
GROUP BY DATE(`wiki_helpfulvote`.`created`)
) as positive_votes
ON all_votes.created_date=positive_votes.created_date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment