Created
March 2, 2012 13:10
-
-
Save timkeller/1958298 to your computer and use it in GitHub Desktop.
For a simple user awards system: Show all users who received more than 3 awards in a single calendar week. Exclude awards that have already been issued.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT user_id, | |
COUNT(*) AS num, | |
date_format(creation_date, '%Y%u') AS theweek, | |
FROM awards | |
WHERE issued = 0 | |
GROUP BY user_id, theweek | |
HAVING num >= 3; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment