Skip to main content
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

ParameterDescriptionSupported input types
<expression>The boolean expression used to calculate the resultBOOLEAN
<condition>An optional boolean expression to filter rows used in aggregationBOOL

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 nulltotalprizedollars int null
The French Grand Prix237
The European Grand Prix465
The Desert Dash Rally643
The Turbocharged Championship Series704
The African Grand Prix895

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