Skip to main content

Documentation Index

Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-fc28139c.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Turns a subquery into a table. The function implements views (see 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.

Syntax

view(subquery)

Arguments

  • subquerySELECT query.

Returned value

  • A table.

Examples

Input table:
┌─id─┬─name─────┬─days─┐
│  1 │ January  │   31 │
│  2 │ February │   29 │
│  3 │ March    │   31 │
│  4 │ April    │   30 │
└────┴──────────┴──────┘
Query
SELECT * FROM view(SELECT name FROM months);
Response
┌─name─────┐
│ January  │
│ February │
│ March    │
│ April    │
└──────────┘
You can use the view function as a parameter of the remote and cluster table functions:
Query
SELECT * FROM remote(`127.0.0.1`, view(SELECT a, b, c FROM table_name));
Query
SELECT * FROM cluster(`cluster_name`, view(SELECT a, b, c FROM table_name));