Introduction
Functions returning geometries
Collections
12. ST_NumGeometries
Summary

Instruction

Great! The second function is ST_NumGeometries(geometry). It returns the number of elements in a collection. Here's an example:

SELECT
  id, 
  ST_NumGeometries(geo_data) 
FROM sf_chains;

The query above will show the id of each collection together with the number of elements it contains.

Exercise

How many Royal Crown ATMs are there in the collection with id = 76?

Stuck? Here's a hint!

Simply use the ST_NumGeometries on the geo_data column.

Console

Code editor

Result

TableConsole