WHERE
WHERE
clause allows to filter the data by specifying conditions.
Syntax
SELECT *
FROM table_name
WHERE condition;
If there is a WHERE
clause, it must contain an expression with the Boolean type. This is usually an expression with comparison and logical operators. Rows where this expression evaluates to false are excluded from further transformations or result.
Examples
Logical operators
Supports AND
, OR
as logical operators and can assemble conditions using brackets ().
SELECT * FROM system_metrics
WHERE idc = 'idc0' AND (host = 'host1' OR host = 'host2');
Numeric
Supports =
, !=
, >
, >=
, <
, <=
as comparison operators.
SELECT * FROM system_metrics WHERE cpu_util = 20.0;
SELECT * FROM system_metrics WHERE cpu_util != 20.0;
SELECT * FROM system_metrics WHERE cpu_util > 20.0;
SELECT * FROM system_metrics WHERE cpu_util >= 20.0;
SELECT * FROM system_metrics WHERE cpu_util < 20.0;
SELECT * FROM system_metrics WHERE cpu_util <= 20.0;
List search
Evaluates match or mismatch against a list of elements.
List match
SELECT * FROM system_metrics WHERE idc IN ('idc_a', 'idc_b');
List mismatch
SELECT * FROM system_metrics WHERE idc NOT IN ('idc_a', 'idc_b');
当前内容版权归 GreptimeDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 GreptimeDB .