Let's say I have a table with 3 points,
CREATE TABLE foo ( id int PRIMARY KEY, geog point );
INSERT INTO foo (id, geog) VALUES
( 1, Point(0,0) ),
( 2, Point(1,1) ),
( 3, Point(2,2) );
How can I construct a LINESTRING
with those three points in those three different rows. The resulting WKT should be LINESTRING( 0 0, 1 1, 2 2 )
?
PostGIS does this with a Spatial Aggregate called ST_MakeLine
SELECT ST_MakeLine(geog)
FROM foo
ORDER BY id;