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::={<|<=|>|>=|=|!=}
Specifies the condition for determining a true or false logical value.
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.
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 specification | Meaning |
---|---|---|
1 | comparison-operand X=comparison-operand Y | True if comparison operand X is equal to comparison operand Y. |
2 | comparison-operand X!=comparison-operand Y | True if comparison operand X is not equal to comparison operand Y. |
3 | comparison-operand X<comparison-operand Y | True if comparison operand X is less than comparison operand Y. |
4 | comparison-operand X<=comparison-operand Y | True if comparison operand X is less than or equal to comparison operand Y. |
5 | comparison-operand X>comparison-operand Y | True if comparison operand X is greater than comparison operand Y. |
6 | comparison-operand X>=comparison-operand Y | True if comparison operand X is greater than or equal to comparison operand Y. |
DECIMAL = NUMERIC > FLOAT = DOUBLE > REAL > BIGINT > INTEGER > SMALLINT > TINYINT
WHERE s1.a + s2.a < 5
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;