Hi,<br><br>I am trying to make a query so it parses through all the 16 cities i have in a table called city, and for each city, picks the nearest city, and gives me the distance between both cities.<br><br>This is the query I made :
<br><br>select <br>c.city_name, astext(c.the_geom), distance(c.the_geom, d.the_geom) AS Distance, d.city_name, astext(d.the_geom)<br>from city c, city d <br>where <br>c.city_name = (<br>    select c.city_name order by c.city_name
 ASC <br> )<br>and<br>d.city_name = (<br>       select d.city_name order by d.city_name DESC <br> )<br>group by c.city_name<br>order by Distance DESC<br>LIMIT 1;<br><br>But I am getting this error : ERROR: column "c.the_geom
" must appear in the GROUP BY clause or be used in an aggregate function<br><br>I am seeing no reason why I should add c.the_geom, anyone can enlighten me more on why I should group by the_geom and after all if it does make sense?
<br><br>Thanks<br clear="all"><br>-- <br>Matthew Pulis<br><a href="http://www.solutions-lab.net">www.solutions-lab.net</a> // <a href="http://www.mepa-clan.info">www.mepa-clan.info</a>