Skip to main content
Skip to main content

APPLY modifier

Allows you to invoke some function for each row returned by an outer table expression of a query.

Syntax

SELECT <expr> APPLY( <func> ) FROM [db.]table_name

Example

CREATE TABLE columns_transformers (i Int64, j Int16, k Int64) ENGINE = MergeTree ORDER by (i);
INSERT INTO columns_transformers VALUES (100, 10, 324), (120, 8, 23);
SELECT * APPLY(sum) FROM columns_transformers;
┌─sum(i)─┬─sum(j)─┬─sum(k)─┐
│    220 │     18 │    347 │
└────────┴────────┴────────┘