ST_UNION_AGG
Aggregates multiple GEOMETRY values by repeatedly applying ST_UNION and returns the merged GEOMETRY result.
This function supports GEOMETRY only.
Syntax
ST_UNION_AGG(<geometry>)
Arguments
Return Type
GEOMETRY.
Example
WITH data AS (
SELECT TO_GEOMETRY('POINT(0 0)') AS g
UNION ALL
SELECT TO_GEOMETRY('POINT(1 1)')
)
SELECT ST_ASWKT(ST_UNION_AGG(g)) FROM data;
╭───────────────────────────╮
│ st_aswkt(st_union_agg(g)) │
├───────────────────────────┤
│ MULTIPOINT(0 0,1 1) │
╰───────────────────────────╯