Skip to content

Instantly share code, notes, and snippets.

@atopal
Created September 17, 2013 19:21
Show Gist options
  • Select an option

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

Select an option

Save atopal/6599363 to your computer and use it in GitHub Desktop.
Helpful vote share by source
SELECT all_votes.created_date , google_votes.votes as google_votes, all_votes.votes as all_votes, (google_votes.votes / all_votes.votes*100) as google_share
FROM
(
SELECT DATE(`wiki_helpfulvote`.`created`) as created_date, count(*) as votes
FROM `wiki_helpfulvote`
WHERE `wiki_helpfulvote`.`created` BETWEEN "2012-08-01 0" AND "2013-10-03 0"
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-08-01 0" AND "2013-10-03 0"
AND `wiki_helpfulvotemetadata`.`key` = "referrer"
AND `wiki_helpfulvotemetadata`.`value` LIKE "%google%"
GROUP BY DATE(`wiki_helpfulvote`.`created`)
) as google_votes
ON all_votes.created_date=google_votes.created_date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment