Taking as hypothesis that: * city.geom is in EPSG:4326 * lat, lng in pets table can also be taken as EPSG:4326 * That you want to sum the number of cats and dogs that are in each geometry of the table city * That the geoms in table city do not overlap or if overlaps you don't care to count two times the pets * city has a pk called gid The query that must be built should take the following into account: Convert lat,lng coordinates into postgis geometries in 4326 SELECT ST_SetSRID(ST_MakePoint(lng, lat), 4326) FROM pets; The you must build a query that sums the cats and dogs on each geom: SELECT gid, sum(cats), sum(dogs) FROM city c, pets_with_geom p WHERE ST_Within(p.geom, c.geom) GROUP BY c.gid To build the full query we use a CTE WITH pets_with_geom AS( SELECT cats, dogs, ST_SetSRID(ST_MakePoint(lng, lat), 4326) as geom FROM pets ) SELECT gid, sum(cats), sum(dogs) FROM city c, pets_with_geom p WHERE ST_Within(p.geom, c.geom) GROUP BY c.gid Note: I can't check the query right now, so it can contain errors.