ReferenceSQL ReferenceAggregate Functions

groupFormat

Formats the rows in each group using the specified output format and returns the result as a string.

This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See SQL interface scope.

Formats the rows in each group using the specified output format and returns the result as a string.

The format name is passed as a parameter, and the arguments are the columns to format. Column names are generated as c1, c2, ... in the formatted output.

Syntax

groupFormat(format)(x, y, ...)

Parameters

  • format — Output format name. For example, JSONEachRow, CSV, TabSeparated. String

Arguments

  • x, y, ... — Expressions to format as rows. Any

Returned value

Formatted output for the group. String

Examples

Basic usage

SELECT groupFormat('JSONEachRow')(number, toString(number))
FROM numbers(3)
{"c1":0,"c2":"0"}
{"c1":1,"c2":"1"}
{"c1":2,"c2":"2"}