5. Geospatial Functions : Extent
 
Share this page                  
Extent
EXTENT(n Geometry)
Alias: ST_EXTENT
Returns a bounding rectangle around all the geometries in n.
Result type: point or polygon
Examples:
SELECT ASTEXT(EXTENT(shape)) AS mbr FROM sometable;
---------------------------------
mbr 
---------------------------------
POLYGON((13.08 52.34, 13.08 52.68, 13.75 52.68, 13.75 52.34, 13.08 52.34))
---------------------------------
 
SELECT type, ASTEXT(EXTENT(shape) AS mbr FROM sometable GROUP BY type;
 
---------------------------------
type     | mbr
---------------------------------
school   | POLYGON((13.12 52.39, 13.12 52.64, 13.70 52.64, 13.70 52.39, 13.12 52.39))
hospital | POLYGON ((13.14 52.38, 13.14 52.64, 13.57 52.64, 13.57 52.38, 13.14 52.38))
---------------------------------