QUERY statement

Subscribes to one or more data sources, processes the incoming rows, and publishes the results into a data stream or named window.

Syntax

insert_clause select_clause from_clause [matching_clause] [on_clause] [where_clause] [group_by_clause] [having_clause] [order_by_clause] [limit_clause] [output_clause] ;
Components

insert_clause

The destination for the published rows. See INSERT Clause for more information.

select_clause

The select list specifying what to publish. See SELECT Clause for more information.

from_clause

The data sources. See FROM Clause for more information.

matching_clause

A pattern-matching specification. See MATCHING Clause for more information.

on_clause

A join condition. See ON Clause for more information.

where_clause

A selection condition. See WHERE Clause for more information.

group_by_clause

A partitioning specification. See GROUP BY Clause for more information.

having_clause

A filter definition. See HAVING Clause for more information.

order_by_clause

A sequencing definition. See ORDER BY Clause for more information.

limit_clause

A limit on the number of rows to publish. See LIMIT Clause for more information.

output_clause

A synchronization specification. See OUTPUT Clause for more information.

Clause Processing Order

The main clauses within a Query statement are processed in the following order, which affects the query's output:

  1. FROM clause (with MATCHING conditions, if any).

  2. WHERE clause (with MATCHING conditions, if any).

  3. SELECT clause (in conjunction with GROUP BY, if present).

  4. HAVING clause.

  5. OUTPUT clause.

  6. ORDER BY clause.

  7. LIMIT clause.

  8. INSERT clause.

See Also

Example

INSERT INTO HourlyStockVolume
SELECT Symbol, SUM(Volume)
FROM StockTrades KEEP EVERY 1 HOUR
GROUP BY Symbol,Buyer
OUTPUT EVERY 1 HOUR;