[postgis-users] sum or not sum..
Michael Smedberg
Michael.Smedberg at redfin.com
Thu Feb 7 09:09:22 PST 2008
I think that your query is counting rows more than once, because you're doing a "Cartesian Product"; see http://www.dba-oracle.com/t_garmany_9_sql_cross_join.htm
I think you'd want to do something like:
select sum(area(a.the_geom)) as sum1,sum(area(b.the_geom))as sum2 from orig1 a,orig2 b where a.id = b.a_id
________________________________
From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Gustavo Ces
Sent: Thursday, February 07, 2008 7:35 AM
To: PostGIS Users Discussion
Subject: [postgis-users] sum or not sum..
Hi all,
I´ve got two tables with geoms. When i try to sum(area) something strange happens:
select sum(area(the_geom)) from orig1
61301.4750045538
select sum(area(the_geom))from orig2
33996.0705435276
but now...
select sum(area(a.the_geom)) as sum1,sum(area(b.the_geom))as sum2 from orig1 a,orig2 b
sum1 sum2
11218169.9258333 4963426.29935503
smells like postgresql basic concept unknowed for me.... :(
Gus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080207/5c43fe65/attachment.html>
More information about the postgis-users
mailing list