geography::CollectionAggregate
spatial aggregate CollectionAggregate
What changes
- Input
- spatial values of each group
- Output or change
- one geometry/geography per group
- Return type
- SQL Server return type: geography
Syntax at a glance
CollectionAggregate ( geography_operand )
Work example
Use geography.CollectionAggregate to collect grouped shapes into one collection result.
Group compatible SRIDs and retain source keys when each input must remain traceable. Keep the geography type and SRID in the review.
Check your work CollectionAggregate gathers both input points into one collection; the component count is 2.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
SELECT geography::CollectionAggregate(v.shape).STNumGeometries() AS collected_count FROM (VALUES (geography::Point(47.651, -122.349, 4326)), (geography::Point(47.656, -122.343, 4326))) AS v(shape);
Open Microsoft Learn for full syntax, permissions, and details for your version.