array

unnest

Expands array elements into rows; use ordinality and ORDER BY to make output order explicit.

Formal Syntax & Structure

sql syntaxsql
unnest(array)

Working Example

Example Snippetsql
SELECT (SELECT string_agg(v::text,',' ORDER BY ord) FROM unnest(ARRAY[8,4,12]) WITH ORDINALITY AS u(v,ord));
SQL Reference