LineStrings can be sliced not only using other geometries, but also based on a fraction of their length. This is done by the ST_LineSubstring function. It accepts three arguments: an input geometry, which must be a LineString (a MultiLineString must be merged using ST_LineMerge), the starting fraction, and the ending fraction. For example, we can extract the first half of the Odra river as follows:
SELECT ST_LineSubstring( (SELECT ST_LineMerge(ST_Collect(wkb_geometry)) FROM lines WHERE name='Odra' AND waterway='river'), 0, 0.5 )
When distance values are needed, ...