I have a dataset of users location and want to assign per user how many other users they have within a given range, and updating this value into a table.The dataset name is "users_20160410" and the column to be updated is "countdistance"
I have manage to get the number of total users within 10km for a given point, which is a unique value:
UPDATE users_20160410 SET countdistance = (select count(*) from users_20160410 where st_distance(the_geom,st_GeomFromText('POINT(-3.703550 40.417192)', 4326), true) < 10000)
What I want is to know for every single user how many other user he has within a range of 10km (this means get a value per user, not 1 unique as per my previous query). Also as the distance is not a fixed given point, the st_Geom_From_Text could not be used as it should take the exact location per user.