Skip to content

Instantly share code, notes, and snippets.

@atopal
Created January 15, 2014 22:09
Show Gist options
  • Save atopal/8445711 to your computer and use it in GitHub Desktop.
Save atopal/8445711 to your computer and use it in GitHub Desktop.
Survey results, from below articles
SELECT
all_votes.created_date,
all_votes.votes as all_votes,
FxFeeback_votes.votes as FxFeeback_votes,
didnt_work_votes.votes as didnt_work_votes,
too_long_votes.votes as too_long_votes,
confusing_votes.votes as confusing_votes,
other_votes.votes as other_votes,
round((FxFeeback_votes.votes / all_votes.votes*100),3) as Fx_Feedback_percentage,
round((didnt_work_votes.votes / all_votes.votes*100),3) as didnt_work_percentage,
round((too_long_votes.votes / all_votes.votes*100),3) as too_long_percentage,
round((confusing_votes.votes / all_votes.votes*100),3) as confusing_percentage,
round((other_votes.votes / all_votes.votes*100),3) as other_percentage
FROM
(
SELECT DATE(`wiki_helpfulvote`.`created`) as created_date, count(*) as votes
FROM `wiki_helpfulvote`
LEFT JOIN `wiki_helpfulvotemetadata` ON `wiki_helpfulvote`.`id`=`wiki_helpfulvotemetadata`.`vote_id`
WHERE `wiki_helpfulvotemetadata`.`key` = "survey"
AND `wiki_helpfulvote`.`created` > '2014-01-01 0'
GROUP BY DATE(`wiki_helpfulvote`.`created`)
) as all_votes
LEFT JOIN
(
SELECT DATE(`wiki_helpfulvote`.`created`) as created_date, count(*) as votes
FROM `wiki_helpfulvote`
LEFT JOIN `wiki_helpfulvotemetadata` ON `wiki_helpfulvote`.`id`=`wiki_helpfulvotemetadata`.`vote_id`
WHERE `wiki_helpfulvotemetadata`.`key` = "survey"
AND `wiki_helpfulvote`.`created` > '2014-01-01 0'
AND `wiki_helpfulvotemetadata`.`value` LIKE '%"unhelpful-reason": "firefox-feedback"%'
GROUP BY DATE(`wiki_helpfulvote`.`created`)
) as FxFeeback_votes
ON all_votes.created_date=FxFeeback_votes.created_date
LEFT JOIN
(
SELECT DATE(`wiki_helpfulvote`.`created`) as created_date, count(*) as votes
FROM `wiki_helpfulvote`
LEFT JOIN `wiki_helpfulvotemetadata` ON `wiki_helpfulvote`.`id`=`wiki_helpfulvotemetadata`.`vote_id`
WHERE `wiki_helpfulvotemetadata`.`key` = "survey"
AND `wiki_helpfulvote`.`created` > '2014-01-01 0'
AND `wiki_helpfulvotemetadata`.`value` LIKE '%"unhelpful-reason": "didnt-work"%'
GROUP BY DATE(`wiki_helpfulvote`.`created`)
) as didnt_work_votes
ON all_votes.created_date=didnt_work_votes.created_date
LEFT JOIN
(
SELECT DATE(`wiki_helpfulvote`.`created`) as created_date, count(*) as votes
FROM `wiki_helpfulvote`
LEFT JOIN `wiki_helpfulvotemetadata` ON `wiki_helpfulvote`.`id`=`wiki_helpfulvotemetadata`.`vote_id`
WHERE `wiki_helpfulvotemetadata`.`key` = "survey"
AND `wiki_helpfulvote`.`created` > '2014-01-01 0'
AND `wiki_helpfulvotemetadata`.`value` LIKE '%"unhelpful-reason": "too-long"%'
GROUP BY DATE(`wiki_helpfulvote`.`created`)
) as too_long_votes
ON all_votes.created_date=too_long_votes.created_date
LEFT JOIN
(
SELECT DATE(`wiki_helpfulvote`.`created`) as created_date, count(*) as votes
FROM `wiki_helpfulvote`
LEFT JOIN `wiki_helpfulvotemetadata` ON `wiki_helpfulvote`.`id`=`wiki_helpfulvotemetadata`.`vote_id`
WHERE `wiki_helpfulvotemetadata`.`key` = "survey"
AND `wiki_helpfulvote`.`created` > '2014-01-01 0'
AND `wiki_helpfulvotemetadata`.`value` LIKE '%"unhelpful-reason": "confusing"%'
GROUP BY DATE(`wiki_helpfulvote`.`created`)
) as confusing_votes
ON all_votes.created_date=confusing_votes.created_date
LEFT JOIN
(
SELECT DATE(`wiki_helpfulvote`.`created`) as created_date, count(*) as votes
FROM `wiki_helpfulvote`
LEFT JOIN `wiki_helpfulvotemetadata` ON `wiki_helpfulvote`.`id`=`wiki_helpfulvotemetadata`.`vote_id`
WHERE `wiki_helpfulvotemetadata`.`key` = "survey"
AND `wiki_helpfulvote`.`created` > '2014-01-01 0'
AND `wiki_helpfulvotemetadata`.`value` LIKE '%"unhelpful-reason": "other"%'
GROUP BY DATE(`wiki_helpfulvote`.`created`)
) as other_votes
ON all_votes.created_date=other_votes.created_date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment