[postgis-users] SUM() for lines

Pavel Iacovlev iacovlev.pavel at gmail.com
Wed Aug 26 10:44:08 PDT 2009


If I understood correctly you need something like this:

SELECT the_geom, height, (SELECT sum(height) FROM
fondcart_layers.relief as t2 where @t1.gid > t2.gid ) as height_sum
FROM  fondcart_layers.relief as t1 LIMIT 10;

this query runs on the table with the following structure:
gid, height (your info column), the_geom

it uses sub selects, to get better performance should be rewritten in
a JOIN query.

2009/8/26 Daniel Grum <daniel.grum at unibw.de>:
> Hi all,
>
> how can I sum the atributes of any lines of one column --> how I can sum the
> info of a column.
> I want to save all avaible resources(all polygons) in an extra column next
> to the resources of one polygon?!
>
> like this:
> gid(integer) | flaeche(double precision) | sum_flaeche(double precision)
>  1                            2000                                      2000
>  2                            5000                                      7000
>  3                             100
> 7100
>
> And how I can select the last info of the column: sum_flaeche to wok with
> the number-->in this case: 7100
>
> If this could not work please describe me another possible way?!
>
> --daniel
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



-- 
http://iap.md, The future is open



More information about the postgis-users mailing list