PostgreSQL unnest(anymultirange) Function

The PostgreSQL unnest(anymultirange) function expands a multirange into a set of range values.

PostgreSQL unnest() Syntax

Here is the syntax of the PostgreSQL unnest(anymultirange) function:

unnest(anymultirange) -> setof anyrange

Parameters

anymultirange

Required. A multirange.

Return value

The PostgreSQL unnest() function expands a multirange value into a set of range values. The range values ​​in the set are in ascending order.

PostgreSQL unnest() Examples

Here are some examples of the PostgreSQL unnest() function.

SELECT unnest('{(1, 3), [10, 20], [5,7]}'::int4multirange);
 unnest
---------
 [2,3)
 [5,8)
 [10,21)