The ST_GeomCollectionAggr aggregate function can be used to combine a group of
geometries into a single collection.
All of the geometries to be combined must have both the same SRID
and the same coordinate dimension.
Rows where the argument is NULL are not included.
Returns NULL for an empty group or a group containing no non-NULL values.
The resulting ST_GeomCollection has the same coordinate dimension as each geometries.
The optional ORDER BY clause can be used to arrange the elements in a particular
order so that ST_GeometryN returns them in the desired order. If this ordering
is not relevant, it is more efficient to not specify an ordering. In that case,
the ordering of elements depends on the access plan selected by the query optimizer.