Postgres 11 JSONB - How to get all distinct values of a field across all elements
Use jsonb_array_elements_text:
SELECT DISTINCT a.e -&gt;&gt; 'stopType' AS &quot;stopType&quot;
FROM shipments AS s
   CROSS JOIN LATERAL jsonb_array_elements_text(s.metadata-&gt;'stops') AS a(e);