[postgis-users] Compare data in one table

Kevin Neufeld kneufeld at refractions.net
Fri Aug 29 18:49:39 PDT 2008


What about something like this.

SELECT a.to_point, a.in_size, b.out_size
FROM
  (SELECT to_point, max(size) AS in_size FROM links GROUP BY to_point) AS a,
  (SELECT from_point, size AS out_size FROM links) AS b
WHERE a.to_point = b.from_point
AND b.out_size < a.in_size;

-- Kevin

Broun Uganda wrote:
> I am trying to develop a trigger function that searches for lines with 
> particular properties. I have two or more lines joining at a point but 
> only one line exiting from that point. I want to check that the size 
> of the outgoing (exiting) line is always not smaller than incoming lines.
> Take such data as example:
> line_name from_point to_point size
> line1        p1              p2          2
> line2        p10             p2         3
> line3        p2            p7            1
> line4        p7            p8            3
>
> Lines Line1 and Line2 join at point p2 (to_point), therefore line3 
> should have size at least equal to 3.
> Tried to use this select statement but doesnt work, could anyone give 
> me an idea
> Select link_name, diameter, from_node, to_node from links as ends 
> where ends.diameter< links.diameter;
> or even
> SELECT   from_node from links as dstream  intersect SELECT   to_node 
> from links as previo ;
>
> Thank you
>
> Broun Uganda
>
> ------------------------------------------------------------------------
> Discover the new Windows Vista Learn more! 
> <http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE>
> ------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>   



More information about the postgis-users mailing list