3

I would like to count the number of smaller polygons (lakes) within three specific polygons (counties). I have been able to get the to data sets to show up in the queried table but can not get the SUM of the lakes. I believe you are suppose to use the SUM but do not know where to place it without getting an error.

SELECT c.county, a.name
FROM public.counties AS c INNER JOIN
     public.lakes AS a ON ST_Intersects(c.geom, a.geom)
WHERE c.county = 'JEFFERSON'
OR c.county = 'DENVER' 
OR c.county = 'ADAMS'
GROUP BY c.county, a.name;
Kersten
  • 9,899
  • 3
  • 37
  • 59
  • SUM will add records (if they're numerical) together, whereas COUNT will tally up the number of records. I don't know the exact code you need, but what you are looking to do is an aggregate query – Knightshound Apr 28 '17 at 14:26
  • This might be an answer to you problem: https://gis.stackexchange.com/a/54680/73835 – Knightshound Apr 28 '17 at 14:32
  • select c.county,a.name,count(a.id) --id refers to any unique id in the lakes table – ziggy Apr 28 '17 at 14:39
  • Use COUNT instead of SUM and take out the a.name in the select and group by as you're not going get anything useful out of that - you're just looking for a count by county – DPSSpatial_BoycottingGISSE Apr 28 '17 at 16:56

0 Answers0