4.4.18 Comparison predicate

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

(1) Format

For the WHERE clause

comparison-predicate::=value-expression comparison-operator value-expression
   comparison-operator::={<|<=|>|>=|=|!=}

For the HAVING clause

comparison-predicate::=comparison-operand comparison-operator comparison-operand
   comparison-operand::={column-specification|column-name|aggregate-function|constant}
   comparison-operator::={<|<=|>|>=|=|!=}

(2) Function

Specifies the condition for determining a true or false logical value.

(3) Operands

value-expression

For details about specifying a value expression, see 4.4.19 Value expression.

comparison-operator

Specify <, <=, >, >=, =, or != as the comparison operator.

comparison-operand

Specify a column specification, an aggregate function, or a constant as the targets of the comparison.

If the preceding FROM clause only references a single relation, you can specify just a column name for that comparison operand.

column-specification
For details about column specification, see 3.2.4 Specifying names.
column-name
If the succeeding FROM clause only references a single relation, you can specify just a column name.
If the succeeding FROM clause references multiple relations, you must use a column specification.
aggregate-function
For details about aggregate functions, see 4.4.12 Aggregate functions.
constant
For details about constants, see 4.4.20 Constant.

(4) Syntax rules

The following table shows the meanings of comparison operators, using comparison operand X, the comparison operator, and comparison operand Y as comparison predicates.

Table 4-7 Comparison operator types and functions

No.Comparison operator specificationMeaning
1comparison-operand X=comparison-operand YTrue if comparison operand X is equal to comparison operand Y.
2comparison-operand X!=comparison-operand YTrue if comparison operand X is not equal to comparison operand Y.
3comparison-operand X<comparison-operand YTrue if comparison operand X is less than comparison operand Y.
4comparison-operand X<=comparison-operand YTrue if comparison operand X is less than or equal to comparison operand Y.
5comparison-operand X>comparison-operand YTrue if comparison operand X is greater than comparison operand Y.
6comparison-operand X>=comparison-operand YTrue if comparison operand X is greater than or equal to comparison operand Y.

(5) Notes

(6) Usage example

Outputs data in which the value of column a in relation s1 is less than 5. The underlined part indicates a comparison predicate.

REGISTER QUERY q1 SELECT * FROM s1[RANGE 10 SECOND] WHERE s1.a < 5;