GROUP BY clause

Affects the behaviour of aggergate functions and the OUTPUT clause in the Query statement, database statement, or Remote procedure statement.

Syntax

GROUP BY { column | gettimestamp } [, ...]
Components

columns

The name of a column in one of the data sources, to partition by value in this column.

gettimestamp

A GETTIMESTAMP function, to partition by the row timestamp.

Usage

The optional GROUP BY clause specifies a list of one or more column references. The list can also contain a GETTIMESTAMP (Scalar Function) function. This clause has the following effect on the behavior of aggregators, window contents, and the OUTPUT clause, where combination refers to a unique combination of values in the list of columns and, optionally, the timestamp referenced by the GROUP BY clause.

See Also

Examples

The following example calculates the average price separately for each symbol in the NamedWindow.Symbol column.

INSERT INTO OutStream
SELECT Symbol AS Symbol, AVG(Price) AS Average
FROM NamedWindow
GROUP BY Symbol;

This example calculates the average prices as in the previous example, but uses an unnamed window that retains ten rows for each value in the Symbol column.

INSERT INTO OutStream
SELECT Symbol AS Symbol, AVG(Price) AS Average
FROM InStream KEEP 10 ROWS
GROUP BY Symbol;