The ST_LineStringAggr aggregate function can be used to build a linestring out of a group
of ordered points.
All of the geometry columns to be combined must have the same SRID.
All of the points to be combined must be non-empty with the same coordinate dimension.
Rows where the linestring-expression is NULL are not included.
Returns NULL for an empty group or a group containing no non-NULL values.
The resulting linestring has the same coordinate dimension as each point.
Note
The ORDER BY clause should be specified to control the order of points within the
linestring. If not present, the order of points in the linestring will vary depending on the
access plan selected by the query optimizer.
Note
By default, ST_LineStringAggr uses the original format for a geometry, if it is available. Otherwise, the internal format
is used. For more information about internal and original formats, see STORAGE FORMAT clause, CREATE SPATIAL REFERENCE SYSTEM statement.