I would like to calculate a cluster of points and for each cluster get the sum of a certain attribute (say, the sum of the estimates of each point in the cluster)
I have already managed to create clusters using ST_ClusterWithin , but I can not calculate the sum.
Here is what I tried:
SELECT sum(score), unnest(ST_ClusterWithin(coordinates, 0.1)) AS cluster FROM locations GROUP BY cluster;
But I get the following ERROR: aggregate functions are not allowed in GROUP BY error ERROR: aggregate functions are not allowed in GROUP BY
If I delete GROUP BY , I will get a valuation amount for all locations, which I don't want (I want a sum for locations in the cluster)
postgresql postgis
Chris
source share