UNNEST operator takes an ARRAY and returns a table, with one row for each element in the ARRAY. You can also use UNNEST outside of the FROM clause with the IN operator.

For input ARRAYs of most element types, the output of UNNEST generally has one column. This single column has an optional alias, which you can use to refer to the column elsewhere in the query. ARRAYS with these element types return multiple columns:

STRUCT UNNEST destroys the order of elements in the input ARRAY. Use the optional WITH OFFSET clause to return a second column with the array element indexes (see below).

For an input ARRAY of STRUCTs, UNNEST returns a row for each STRUCT, with a separate column for each field in the STRUCT. The alias for each column is the name of the corresponding STRUCT field.

You can read much more about UNNESTin a much more applicable section - FROM clause - go there and scroll a little down till UNNEST section

Answer from Mikhail Berlyant on Stack Overflow
🌐
w3resource
w3resource.com › PostgreSQL › postgresql_unnest-function.php
PostgreSQL PostgreSQL UNNEST() function - w3resource
2 weeks ago - -- Selecting the p_id column and ... -- From the test table ... This SQL query selects the p_id column and uses the unnest() function to expand the p_name array column from the test table....
🌐
StarRocks
docs.starrocks.io › reference › sql functions › array › unnest
unnest | StarRocks
UNNEST is a table function that takes an array and converts elements in that array into multiple rows of a table. The conversion is also known as "flattening".
People also ask

What is unnest in PostgreSQL?
The UNNEST function in PostgreSQL is used to expand an array into a set of rows. It takes an array and returns a set of rows, each containing one element of the array.
🌐
hevodata.com
hevodata.com › home › learn › database management system
PostgreSQL UNNEST() Function: Syntax &amp Examples Explained
How to unnest text in PostgreSQL?
If you have text data that is delimited by a specific character (e.g., commas or spaces) and you want to split this text into separate rows, you can combine UNNEST with STRING_TO_ARRAY.
🌐
hevodata.com
hevodata.com › home › learn › database management system
PostgreSQL UNNEST() Function: Syntax &amp Examples Explained
What is the opposite of Unnest in PostgreSQL?
The opposite of UNNEST would be to aggregate rows into a single array. In PostgreSQL, you can use the ARRAY_AGG function to aggregate rows into an array.
🌐
hevodata.com
hevodata.com › home › learn › database management system
PostgreSQL UNNEST() Function: Syntax &amp Examples Explained
🌐
Vertica
docs.vertica.com › 12.0.x › en › sql-reference › functions › data-type-specific-functions › collection-functions › unnest
UNNEST | Vertica 12.0.x
April 5, 2023 - Whether to skip partitioning and ignore the OVER clause if present. UNNEST translates a single row of input into multiple rows of output, one per collection element. There is, therefore, usually no benefit to partitioning the input first.
🌐
Vertica
docs.vertica.com › 24.1.x › en › sql-reference › functions › data-type-specific-functions › collection-functions › unnest
UNNEST | Vertica 24.1.x
August 2, 2023 - Whether to skip partitioning and ignore the OVER clause if present. UNNEST translates a single row of input into multiple rows of output, one per collection element. There is, therefore, usually no benefit to partitioning the input first.
🌐
Imply
docs.imply.io › unnesting arrays
Unnest arrays within a column | Imply
This tutorial demonstrates how to use the unnest datasource to unnest a column that has data stored in arrays. For example, if you have a column named dim3 with values like [a,b] or [c,d,f], the unnest datasource can output the data to a new column with individual rows that contain single values like a and b.
Top answer
1 of 2
10

UNNEST operator takes an ARRAY and returns a table, with one row for each element in the ARRAY. You can also use UNNEST outside of the FROM clause with the IN operator.

For input ARRAYs of most element types, the output of UNNEST generally has one column. This single column has an optional alias, which you can use to refer to the column elsewhere in the query. ARRAYS with these element types return multiple columns:

STRUCT UNNEST destroys the order of elements in the input ARRAY. Use the optional WITH OFFSET clause to return a second column with the array element indexes (see below).

For an input ARRAY of STRUCTs, UNNEST returns a row for each STRUCT, with a separate column for each field in the STRUCT. The alias for each column is the name of the corresponding STRUCT field.

You can read much more about UNNESTin a much more applicable section - FROM clause - go there and scroll a little down till UNNEST section

2 of 2
3

The outer query that selects from events_20180725 introduces the event_params into the scope of the select list. When you put a scalar subquery in the select list, that subquery can reference columns from the outer scope. The UNNEST function returns a relation given a column reference, which introduces other columns into the scope of the subquery, namely key and value in this case. In the case of this scalar subquery:

(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'TITLE')

Filtering on key = 'TITLE' restricts the rows returned by UNNEST just to the one where the key has that value.

Find elsewhere
🌐
Count
count.co › sql-resources › bigquery-standard-sql › unnest
UNNEST | BigQuery Standard SQL - Count.co
UNNEST function. Definition, syntax, examples and common errors using BigQuery Standard SQL. The UNNEST function takes an ARRAY and returns a table with a row for each element in the ARRAY.
🌐
IBM
ibm.com › docs › en › db2-big-sql › 7.1.0
UNNEST table function
The UNNEST function returns a result table that includes a row for each element of the specified array. If there are multiple ordinary array arguments specified, the number of rows will match the array with the largest cardinality.
🌐
Hevo
hevodata.com › home › learn › database management system
PostgreSQL UNNEST() Function: Syntax &amp Examples Explained
January 9, 2026 - PostgreSQL unnest() function is essential in data manipulation. In this section, we will go through some fundamental unnest operations, their functionality, and examples. These operations will aid us in dealing with PostgreSQL Unnest functions efficiently. Let’s address them one by one.
🌐
Medium
medium.com › @kandaanusha › unnest-in-sql-cb7159cb2714
UNNEST in SQL. UNNEST is a SQL function that expands a… | by Kandaanusha | Medium
September 3, 2025 - In this example, t.array_column is the column containing the array you want to expand. The UNNEST function takes this array and, for each row in your_table, it generates a new row for every element in that array.
🌐
Oracle
docs.oracle.com › en › database › other-databases › nosql-database › 23.1 › sqlreferencefornosql › unnest-arrays-maps.html
Unnest Arrays & Maps
October 12, 2023 - Use unnest_syntax to flatten rows that include arrays or maps · The FROM clause of a SELECT statement may contain a list of expressions (with associated variables). Normally, you will use expressions that unnest arrays or maps and the FROM clause will create a new set of rows out of the values ...
🌐
Teradata
docs.teradata.com › r › Enterprise_IntelliFlex_VMware › SQL-Data-Types-and-Literals › ARRAY › VARRAY-Functions-and-Operators › UNNEST › Example-Calling-UNNEST
Example: Calling UNNEST - Teradata Vantage
Loading application · Promo placeholder · Tracking Consent Teradata.com · Developers · Getting Started · VantageCloud Lake Documentation AI Unlimited All Documentation · Downloads · Community · Teradata Community Technical Medium Blogs Github Stack Overflow · Try for free
🌐
CommandPrompt Inc.
commandprompt.com › education › postgresql-unnest-function-with-examples
PostgreSQL UNNEST() Function With Examples — CommandPrompt Inc.
September 12, 2022 - PostgreSQL provides a built-in function named UNNEST() that accepts an array as an argument and expands the given array into a set of rows. The UNNEST() function can accept the array of any data type, such as text, int, etc., and expands the ...
🌐
Sql-workbench
sql-workbench.eu › comparison › unnest.html
UNNEST
The SQL standard defines the UNNEST function to return a result table with one row for each element of an array.
🌐
DuckDB
duckdb.org › docs › current › sql › query_syntax › unnest
Unnesting – DuckDB
Examples Unnest a list, generating 3 rows (1, 2, 3): SELECT unnest([1, 2, 3]); Unnesting a struct, generating two columns (a, b): SELECT unnest({'a': 42, 'b': 84}); Recursive unnest of a list of structs: SELECT unnest([{'a': 42, 'b': 84}, {'a': ...
🌐
W3Schools
w3schools.com › sql › sql_syntax.asp
SQL Syntax
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
🌐
W3Schools
w3schools.com › sql › sql_examples.asp
SQL Examples
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
🌐
EDUCBA
educba.com › home › data science › data science tutorials › postgresql tutorial › postgresql unnest
PostgreSQL Unnest | How does Unnest Function work in PostgreSQL?
May 22, 2023 - Guide to PostgreSQL Unnest. Here we discuss the introduction, how unnest function works in PostgreSQL? and examples respectively.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai