# Set Returning Functions

This section describes functions that return multiple rows.
You can call set-returning functions in the [FROM clause](/docs/data/data-cloud-query-guide/references/dc-sql-reference/select.md#clauses) of a SQL query:

```sql
SELECT * FROM unnest(ARRAY['Mon','Tue','Wed','Thu','Fri']) AS days(day)
```

## Functions

- [`unnest`](/docs/data/data-cloud-query-guide/references/dc-sql-reference/unnest.md) - Expands the elements of an array.
- [`external`](/docs/data/data-cloud-query-guide/references/dc-sql-reference/external.md) - Reads data stored in an external file format from one or multiple external locations.
- [`generate_series` (Numerical)](/docs/data/data-cloud-query-guide/references/dc-sql-reference/generate-series.md) - Generates a series of numerical values from start to stop with a given step size.
- [`generate_series` (Time-based)](/docs/data/data-cloud-query-guide/references/dc-sql-reference/generate-series-time.md) - Generates a series of date or timestamp values from start to stop with a given interval step size.
- [`regexp_matches`](/docs/data/data-cloud-query-guide/references/dc-sql-reference/regexp-matches.md) - Returns the captured groups of each match of a regular expression pattern.
- [`result_scan`](/docs/data/data-cloud-query-guide/references/dc-sql-reference/result-scan.md) - Returns the result set of a previously executed query as a table. Available in Data 360 SQL only.

## `WITH ORDINALITY`

In SQL, all row sets are unordered by default.
Due to implementation details such as parallelization, rows might be processed and output in any order.

Sometimes, the order of rows generated by a set-returning function is important, though.
In such cases, the `WITH ORDINALITY` clause can be used to add an additional output column, assigning a sequential number to the generated rows:

```sql
SELECT *
FROM unnest(ARRAY['Mon','Tue','Wed','Thu','Fri']) WITH ORDINALITY AS days(day, ordinality)
ORDER BY ordinality
```

Results:

| day | ordinality |
| :-- | :--------- |
| Mon | 1          |
| Tue | 2          |
| Wed | 3          |
| Thu | 4          |
| Fri | 5          |

The `WITH ORDINALITY` clause is supported by most, but not all, set-returning functions.

## Related Documentation

- [SELECT](/docs/data/data-cloud-query-guide/references/dc-sql-reference/select.md)
- [FROM Clause](/docs/data/data-cloud-query-guide/references/dc-sql-reference/select-from.md)
