Specifies the expressions on which to perform an aggregation operation.
GROUP BY expression1 [, expression2 ...]
expression |
An expression using constants, which can contain one or more expressions from the input window or stream. However, an expression cannot use aggregate functions. |
It combines one or more result rows into a single row of output. A GROUP BY clause is used when the query result contains aggregate functions to specify what expressions to perform the aggregation operation on.
Use the actual expression in the GROUP BY clause, rather than the alias for that expression which prevents the project from compiling. For example, use the expression T.Symbol instead of an alias like Symbol.
The GROUP BY clause collects together the rows according to T.Symbol:
CREATE WINDOW Window1 SCHEMA (Symbol STRING, MaxPrice INTEGER) PRIMARY KEY DEDUCED KEEP ALL AS SELECT T.Symbol, max(T.Price) MaxPrice FROM Trades T GROUP FILTER rank() < 10 GROUP BY T.Symbol GROUP ORDER BY T.Volume DESC HAVING max(T.Price) > 100 AND T.Symbol ='IBM';