ST_LocateBetweenElevations — Returns the portions of a geometry that lie in an elevation (Z) range.
geometry ST_LocateBetweenElevations(geometry  geom, float8  elevation_start, float8  elevation_end);
Returns a geometry (collection) with the portions of a geometry that lie in an elevation (Z) range.
Clipping a non-convex POLYGON may produce invalid geometry.
Availability: 1.4.0
Enhanced: 3.0.0 - added support for POLYGON, TIN, TRIANGLE.
            
            This function supports 3d and will not drop the z-index.
        
SELECT ST_AsText(
  ST_LocateBetweenElevations(
    'LINESTRING(1 2 3, 4 5 6)'::geometry,
    2, 4 ));
             st_astext
-----------------------------------
 MULTILINESTRING Z ((1 2 3,2 3 4))
SELECT ST_AsText(
    ST_LocateBetweenElevations(
      'LINESTRING(1 2 6, 4 5 -1, 7 8 9)',
      6, 9)) As ewelev;
                                ewelev
-----------------------------------------------------------------------
 GEOMETRYCOLLECTION Z (POINT Z (1 2 6),LINESTRING Z (6.1 7.1 6,7 8 9))