Returns true if all non NULL input value are true, otherwise false. If all input values are NULL values, returns NULL.
Syntax
BOOL_AND(<expression>) [FILTER ([WHERE] <condition>)]
Parameters
| Parameter | Description | Supported input types |
|---|
<expression> | The boolean expression used to calculate the result | BOOLEAN |
<condition> | An optional boolean expression to filter rows used in aggregation | BOOL |
Return Types
BOOLEAN
Example
The following query shows a sample of tournaments with the lowest prize amounts, demonstrating that even small-prize tournaments still have positive values:
SELECT name, totalprizedollars FROM tournaments ORDER BY totalprizedollars LIMIT 5;
| name text null | totalprizedollars int null |
|---|
| The French Grand Prix | 237 |
| The European Grand Prix | 465 |
| The Desert Dash Rally | 643 |
| The Turbocharged Championship Series | 704 |
| The African Grand Prix | 895 |
Rows: 5Execution time: 6.00ms
The following example checks whether every tournament in the tournaments table has a non-null, positive prize amount:
SELECT BOOL_AND(totalprizedollars IS NOT NULL AND totalprizedollars > 0) AS all_have_prizes FROM tournaments;
| all_have_prizes boolean null |
|---|
| True |
Rows: 1Execution time: 8.72ms