Skip to content

Instantly share code, notes, and snippets.

@danieliser
Created December 3, 2017 17:53
Show Gist options
  • Select an option

  • Save danieliser/81d0616cc414bcfeb4c13dc91175d07e to your computer and use it in GitHub Desktop.

Select an option

Save danieliser/81d0616cc414bcfeb4c13dc91175d07e to your computer and use it in GitHub Desktop.
Several queries used to pull review tracking data.
/**
* Returns count of unique site/user combinations.
*/
SELECT count(DISTINCT(uuid)) FROM `pmapi_pum_reviews`
/**
* Get count of each reason.
* Use Having to limit these results or pivot the table.
*/
SELECT `reason`, COUNT(*) FROM `pmapi_pum_reviews` GROUP BY `reason`
/**
* Get count & percentage of each reason.
* Use Having to limit these results or pivot the table.
*/
SELECT reason, COUNT(*) AS count, concat(FORMAT((SUM(100) / total),2),'%') AS percentage FROM `pmapi_pum_reviews` CROSS JOIN (SELECT COUNT(*) AS total FROM `pmapi_pum_reviews` ) x GROUP BY reason
/**
* Get list of reasons with more than 3 submissions.
*/
SELECT `reason`, count(*) from `pmapi_pum_reviews` group by `reason` having count(*) > 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment