The WINDOW clause is a “rolling” query over a given period of time, such as an hour, used to execute queries along the lines of “give me all orders within the past hour” or “give me all vehicle with speeds over 55 for the past five minutes". Because streaming data continually updates, windows are an important part of both querying and performing calculations on streaming data.
The WINDOW clause allows you to define named window specifications that can be used in analytic function calls and streaming JOIN clauses elsewhere in the query. The windows so defined are inherited by sub-queries of the current query.
- A tumbling window specifies a time frame that continually updates over time. For example, a tumbling window might specify a following hour. The window is “tumbling” because after the output rows are emitted, the tumbling window is cleared and a new set of future rows are accumulated for the next output. As a result, the total number of output rows are limited. Tumbling windows can be used with streaming aggregation (SELECT STREAM … GROUP BY). Tumbling windows can be used with Streaming Aggregation (SELECT STREAM … GROUP BY). For more details, see the topic GROUP BY clause in the s-Server Streaming SQL Reference Guide.
- A sliding or rolling window emits an output row with every input row and flushes a small number (often times 1) row out of the window for the next calculation. Sliding or rolling windows continue to accumulate rows, aside from the small number flushed. These are used for windowed aggregation.