Created
August 23, 2016 13:42
-
-
Save ramiroaznar/e85e223ae31b34a56bb72616be6c5fc5 to your computer and use it in GitHub Desktop.
Select and count points within a polygon
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 | |
pa.*, | |
array_to_string(array_agg(cp.cartodb_id), ', ') as ids, | |
count(cp.*) as count_clients | |
FROM | |
ramirocartodb.clients_points cp RIGHT JOIN ramirocartodb.protected_areas pa ON | |
ST_Intersects(cp.the_geom, pa.the_geom) | |
GROUP BY | |
pa.cartodb_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment