Created
September 4, 2012 19:57
-
-
Save gphil/3625707 to your computer and use it in GitHub Desktop.
Using GROUP BY instead of HAVING
This file contains hidden or 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 icps.city, icps.state, icps.ice_cream_parlor | |
FROM ice_cream_parlors icps | |
INNER JOIN ( | |
SELECT city, state, count(ice_cream_parlor) icp_count | |
FROM ice_cream_parlors icps | |
GROUP by city, state | |
) sq | |
ON icps.city = sq.city and icps.state = sq.state | |
GROUP BY icps.city, icps.state, icps.ice_cream_parlor | |
WHERE sq.icp_count > 5; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment