Hi all.<div><br></div><div>I have two point data sets. One point set is health observations, the other one is conflicts.</div><div>What i want to do is to calculate the average distance from each health observation to the 10 nearest conflict points.</div>
<div>I have managed to calculate the average distance, but only to all conflict points.</div><div><br></div><div>My query:</div><div><div>select "LBGE51FL".the_geom, "LBGE51FL".gid, AVG(ST_Distance(ST_Transform("LBGE51FL".the_geom, 954010), ST_Transform(acled.the_geom, 954010)))/1000 AS dist INTO LB_dist FROM "LBGE51FL", acled WHERE acled.gwno = 450 GROUP BY "LBGE51FL".the_geom, "LBGE51FL".gid;</div>
</div><div><br></div><div>SRID 954010 is Eckert VI.</div><div><br></div><div>Any idea on how to limit this query to the 10 nearest points?</div><div><br></div><div>Thanks.</div><div><br></div><div>Andreas</div>