ANY and EVERY

ANY

ANY returns true if the supplied boolean_expression is true in any of the selected rows; and returns false if the supplied boolean_expression is true in none of the selected rows.

ANY is the dual of EVERY.

Syntax

ANY ( <boolean_expression> )

Example

The following SQL snippet returns ‘true’ if the price for any ticker in the stream of trades is below 1; and ‘false’ if every price in the stream is 1 or greater.

SELECT ANY (ticker < 1) FROM trades
GROUP BY (FLOOR trades.rowtime to hour);

EVERY

EVERY returns true if the supplied boolean_expression is true in all of the selected rows, and returns false otherwise, that is, if the supplied boolean_expression is false in any of the selected rows.

EVERY is the dual of ANY.

Syntax

EVERY ( <boolean_expression> )

Example

The following SQL snippet returns ‘true’ if the price for every ticker in the stream of trades is below 1; and ‘false’ if any price is 1 or greater. ```sql SELECT EVERY (ticker < 1) FROM trades GROUP BY (FLOOR trades.rowtime to hour)