Skip to content

Bool ​

Bool represents the two logical values true and false. BOOLEAN is an alias.

Syntax ​

text
Bool
BOOLEAN

Accepted values ​

A Boolean conversion accepts true, false, numeric 0 and 1, and their equivalent flag text. Other numeric values are rejected rather than treated as true.

Boolean columns can be used directly in WHERE, CASE and conditional aggregate expressions. SQL NULL remains a missing value; declare NOT NULL when a column must always have a flag.

Examples ​

Converting flags ​

sql
SELECT CAST('true' AS Bool), CAST(0 AS Bool), CAST(1 AS BOOLEAN)
FORMAT csv;
text
true,false,true

Filtering by a Boolean column ​

sql
CREATE TABLE tasks(id UInt32, completed Bool NOT NULL);
INSERT INTO tasks VALUES (1, true), (2, false), (3, true);
sql
SELECT id
FROM tasks
WHERE completed
ORDER BY id
FORMAT csv;
text
1
3

See logical functions and NULL functions for Boolean expressions with missing values.