Returns TRUE if AT LEAST ONE value in the group is TRUE. Acts as an aggregated OR operator, useful for checking whether any condition in a set is met.
BOOLDiperbarui: 13 Jun 2026LOGICAL_OR(expression)The boolean expression to OR together
1 SELECT 2 batch_id, 3 LOGICAL_OR(has_error) as any_errors, 4 LOGICAL_OR(is_warning) as any_warnings 5 FROM `project.dataset.batch_logs` 6 GROUP BY batch_id;
Checks whether any error or warning occurred in each batch.
| batch_id | any_errors | any_warnings |
|---|---|---|
| B001 | FALSE | TRUE |
| B002 | TRUE | TRUE |
| B003 | FALSE | FALSE |
1 SELECT 2 user_id, 3 LOGICAL_OR(used_feature_a) as ever_used_a, 4 LOGICAL_OR(used_feature_b) as ever_used_b, 5 LOGICAL_OR(used_premium) as ever_used_premium 6 FROM `project.dataset.user_activity` 7 GROUP BY user_id 8 HAVING LOGICAL_OR(used_premium) = TRUE;
Finds users who have ever used a premium feature.
| user_id | ever_used_a | ever_used_b | ever_used_premium |
|---|---|---|---|
| U001 | TRUE | TRUE | TRUE |
| U002 | FALSE | TRUE | TRUE |
1 SELECT 2 service_name, 3 LOGICAL_OR(cpu_critical) as cpu_alert, 4 LOGICAL_OR(memory_critical) as memory_alert, 5 LOGICAL_OR(disk_critical) as disk_alert, 6 LOGICAL_OR(cpu_critical OR memory_critical OR disk_critical) as any_alert 7 FROM `project.dataset.system_metrics` 8 WHERE timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR) 9 GROUP BY service_name;
Monitors alert status per service over the past hour.
| service_name | cpu_alert | memory_alert | disk_alert | any_alert |
|---|---|---|---|---|
| api-gateway | TRUE | FALSE | FALSE | TRUE |
| database | FALSE | TRUE | FALSE | TRUE |
| cache | FALSE | FALSE | FALSE | FALSE |
Sudah paham LOGICAL_OR? Latih langsung di browser
Latihan interaktif, langsung di browser.