4.4.15 Window specification

Organization of this subsection
(1) Format
(2) Function
(3) Operands
(4) Syntax rules
(5) Notes
(6) Usage examples

(1) Format

window-specification::={ROWS[Figure]integer-constant
                 |RANGE[Figure]integer-constant[[Figure]time-specification]
                 |NOW
                 |PARTITION[Figure]BY[Figure]column-specification-list[Figure]ROWS[Figure]integer-constant}

(2) Function

Specifies how long data is retained in a stream. Window specification is entered in a relation reference.

(3) Operands

ROWS

Specify a value in the range from 1 to 100,000 for the number of rows that are retained in the stream.

RANGE

Specifies how long data stays in the stream. If you specify time division for a query, you must specify RANGE.

integer-constant

Specifies an amount of time. For the range of integer constant values, see 4.4.16 Time specification.

time-specification

Specifies a unit for the time specified in integer-constant. For details about time specification, see 4.4.16 Time specification.

If you do not specify this, the value specified in integer-constant is assumed to be in seconds.

NOW

Only items currently in the stream will be processed.

PARTITION BY

Applies ROWS processing to each column name value specified in the column specification list.

column-specification-list

For details about specifying a column specification list, see 4.4.13 Column specification list.

For the column specification list, you can specify a column name.

(4) Syntax rules

None.

(5) Notes

(6) Usage examples

Usage example 1

Specifies that rows remain in the stream in relation s1 for 2 seconds. The underlined part indicates the window specification.

REGISTER QUERY q1 SELECT * FROM s1[RANGE 2 SECOND];

Usage example 2

Specifies that two rows are to remain in the stream for each value of column a in relation s1. The underlined part indicates the window specification.

REGISTER QUERY q1 SELECT * FROM s1[PARTITION BY s1.a ROWS 2];