Skip to content

Instantly share code, notes, and snippets.

@alancoleman
Created October 3, 2013 15:47
Show Gist options
  • Save alancoleman/6812054 to your computer and use it in GitHub Desktop.
Save alancoleman/6812054 to your computer and use it in GitHub Desktop.
Make two counts at the same time, the first of all users, the second of all active users.
SELECT COUNT(*) AS users, COUNT(IF(a.active BETWEEN '2013-09-01 00:00:00' AND '2013-09-31 23:59:59',1,NULL)) AS active
FROM lsoncc_Users AS u
LEFT JOIN lsoncc_UsersFlags AS a
ON u.userid = a.userid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment