Created
February 12, 2013 00:36
-
-
Save tanelsuurhans/4759002 to your computer and use it in GitHub Desktop.
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 id, | |
sum(hours) AS totalhours | |
FROM mytable | |
GROUP BY id | |
HAVING sum(hours) > 50; | |
If you really can't be bothered to write sum() twice, you could consider | |
a two-level SELECT: | |
SELECT * FROM | |
(SELECT id, | |
sum(hours) AS totalhours | |
FROM mytable | |
GROUP BY id) ss | |
WHERE totalhours > 50; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment