> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8a08bda2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Turns a subquery into a table. The function implements views.

# view

Turns a subquery into a table. The function implements views (see [CREATE VIEW](/reference/statements/create/view)). The resulting table does not store data, but only stores the specified `SELECT` query. When reading from the table, ClickHouse executes the query and deletes all unnecessary columns from the result.

<h2 id="syntax">
  Syntax
</h2>

```sql theme={null}
view(subquery)
```

<h2 id="arguments">
  Arguments
</h2>

* `subquery` — `SELECT` query.

<h2 id="returned_value">
  Returned value
</h2>

* A table.

<h2 id="examples">
  Examples
</h2>

Input table:

```text theme={null}
┌─id─┬─name─────┬─days─┐
│  1 │ January  │   31 │
│  2 │ February │   29 │
│  3 │ March    │   31 │
│  4 │ April    │   30 │
└────┴──────────┴──────┘
```

```sql title="Query" theme={null}
SELECT * FROM view(SELECT name FROM months);
```

```text title="Response" theme={null}
┌─name─────┐
│ January  │
│ February │
│ March    │
│ April    │
└──────────┘
```

You can use the `view` function as a parameter of the [remote](/reference/functions/table-functions/remote) and [cluster](/reference/functions/table-functions/cluster) table functions:

```sql title="Query" theme={null}
SELECT * FROM remote(`127.0.0.1`, view(SELECT a, b, c FROM table_name));
```

```sql title="Query" theme={null}
SELECT * FROM cluster(`cluster_name`, view(SELECT a, b, c FROM table_name));
```

<h2 id="related">
  Related
</h2>

* [View Table Engine](/reference/engines/table-engines/special/view)
