Skip to content

Instantly share code, notes, and snippets.

@dperrymorrow
Last active August 29, 2015 14:11
Show Gist options
  • Save dperrymorrow/186087c69ea9c09552de to your computer and use it in GitHub Desktop.
Save dperrymorrow/186087c69ea9c09552de to your computer and use it in GitHub Desktop.
Percentage query in MySQL
SELECT SUM((SELECT COUNT(*) FROM `posts` WHERE `approved` = 1) /
(SELECT COUNT(*) FROM `posts`) * 100) AS 'Percentage Approved'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment