<html><body bgcolor="#FFFFFF"><div>Try unioning with the opposite condition.<br><br>Sent from my iPod</div><div><br>On Mar 16, 2013, at 11:53 AM, Carsten Hogertz <<a href="mailto:carsten.hogertz@gmail.com">carsten.hogertz@gmail.com</a>> wrote:<br><br></div><div></div><blockquote type="cite"><div>
    <div class="post-text" itemprop="description">
      <p>I've got a simple problem: I want to count the number of points
        within a set of polygons.</p>
      <p>I have a SQL already but it only gives back the gid of the
        polygone that actually contains points.</p>
      <p>My tables: a polygon layer with 19.000 rows and a point layer
        with 450 rows.</p>
      <p>The following SQL </p>
      <pre><code>select grid.gid, count(*) AS totale FROM grid, kioskdhd3 WHERE 
st_contains(grid.geom,kioskdhd3.geom) GROUP BY grid.gid;
</code></pre>
      <p>return only some 320 polygons that actually contain points. But
        I want all polygons returned, even thought the number of points
        is 0.</p>
      <p>Of course it has to do with my WHERE-clause. Where do I have to
        put in my st_contains?</p>
      <p>Thank you
        Carsten</p>
    </div>
  

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>postgis-users mailing list</span><br><span><a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a></span><br><span><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a></span><br></div></blockquote></body></html>